Results 1 to 5 of 5

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

  1. #1
    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.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    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))
    {    
    }

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    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);

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    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 .

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    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  ");

Similar Threads

  1. How to get rid of empty space at start of Excel Cell
    By AdilShaikh18 in forum MS Office Support
    Replies: 2
    Last Post: 09-02-2012, 07:29 PM
  2. Chkdsk doesn't find bad sectors in unused space
    By Landon in forum Windows XP Support
    Replies: 3
    Last Post: 02-04-2010, 09:41 AM
  3. Managing space in string
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 10-02-2010, 03:53 AM
  4. Delete space character after an empty Field
    By Saaz in forum Windows Software
    Replies: 3
    Last Post: 07-07-2009, 01:01 PM
  5. SQL need to check null or empty string
    By B_Hodge in forum Software Development
    Replies: 3
    Last Post: 18-06-2009, 11:44 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,115,294.11112 seconds with 17 queries