|
| |||||||||
| Tags: application, asp dot net, object, program, regex, string |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to find string that doesn't start with empty space?
Hello to all, I am second year Computer science student. I recently started learning c# language. In the last lecture our sir asked us one program like how to find string that doesn't start with empty space? None of us able to give write answers. Can anyone tell me how to find string that doesn't start with empty space? Please help me. Thank you. Last edited by MACE : 02-03-2010 at 05:40 PM. |
|
#2
| ||||
| ||||
| Re: How to find string that doesn't start with empty space?
You have to use ValidationExpression in your code to find string that doesn't start with empty space. It is very simple to do this. I have written following code for you. Just try to understand it. In the following code I have use "^" to find string. Code: string ValidationExpressions = @"/^[^ ]/";
if (!Stringss.IsNullOrEmptys(GroupsNamess) && !Regex.IsMatch(GroupsNames, ValidationExpressions))
{
}
__________________ Grand Theft Auto 4 PC Video Game |
|
#3
| ||||
| ||||
| Re: How to find string that doesn't start with empty space?
As per my information you have to use boolean data type in your code to find string that doesn't start with empty space. I have written small example of it. Just try to understand it. In the following code I have use s1string variable to store input taken from the user. Code: string s1string = " Welcome to this worild"; bool isEmptysStarts = s1string.StartsWith(strings.Emptys);
__________________ The FIFA Manager 2009 PC Game |
|
#4
| ||||
| ||||
| Re: How to find string that doesn't start with empty space?
I think you have to use following symbol in your code to find string that doesn't start with empty space. The "^" is used to find empty space. Code: /^[^ ]/ After that meaning of [^ ] is "one character that is not a space". After that "//" means regex delimiter . |
|
#5
| ||||
| ||||
| Re: How to find string that doesn't start with empty space?
You have to use Regex expression in your code to find string that doesn't start with empty space. It is very simple to do this. In the following code I have use object of regex expression to do this. Code: Regex rxs = new Regex(@"^\ss1+"); Code: Match ms1 = rxs.Match(" ");
Match ms2 = rxs.Match("qwertyu "); |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to find string that doesn't start with empty space?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Chkdsk doesn't find bad sectors in unused space | Borgholio | Windows XP Support | 3 | 02-04-2010 10:41 AM |
| Deleting space in a string in C programming | Ameeryan | Software Development | 4 | 09-03-2010 11:01 PM |
| Managing space in string | Gunner 1 | Software Development | 5 | 10-02-2010 03:53 AM |
| Delete space character after an empty Field | Saaz | Windows Software | 3 | 07-07-2009 02:01 PM |
| SQL need to check null or empty string | B_Hodge | Software Development | 3 | 18-06-2009 12:44 PM |