Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links



How to find string that doesn't start with empty space?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 02-03-2010
Member
 
Join Date: Nov 2009
Posts: 36
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.
Reply With Quote
  #2  
Old 02-03-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,299
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))
{    
}
Reply With Quote
  #3  
Old 02-03-2010
opaper's Avatar
Member
 
Join Date: May 2008
Posts: 2,362
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
Reply With Quote
  #4  
Old 02-03-2010
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,832
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:
/^[^ ]/
In above code "^" means "string starts with"
After that meaning of [^ ] is "one character that is not a space".
After that "//" means regex delimiter .
Reply With Quote
  #5  
Old 02-03-2010
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,502
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+");
After this you have to write following code.
Code:
Match ms1 = rxs.Match("   ");  
  Match ms2 = rxs.Match("qwertyu  ");
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 07:40 AM.