locked
Allowing Spacing but not Special Character

    Question

  •  

    Hi

    Example : Folder Name

     

    If i put ValidationExpression="[A-Za-z0-9^]*"   , this regular expression to prevent special character and also prevent spacing.

     

    How do i add in to allowing Spacing but not special character like @#$%^.[]{} ??

     

    Please help

    Thursday, May 08, 2008 3:32 AM

Answers

  •  

    Thanks.. i found out how

     

    ValidationExpression="^([a-zA-Z0-9_\s\-]*)$"

     

     

    \s = Spacing

    \- =  Allowing dash -

    _ = Allow Underscore

    a-z = Small letter

    A-Z = Capital Letter

    0-9 = Numeric

     

    Thursday, May 08, 2008 7:35 AM

All replies

  • Hi,

     

    "\w"  takes a letter, digit, or space character underscore character. Another alternative is to manually add a space after the digit as shown below:

     

    [a-zA-Z0-9 ]

     

    Note: Even though your question is about regular expressions, the 'validationexpression' reminds me of asp.net. Just wanted to let you know that there is a forum dedicated to asp.net and related technologies at http://forums.asp.net

     

     

    HTH,
    Suprotim Agarwal

    Thursday, May 08, 2008 5:10 AM
    Moderator
  •  Suprotim Agarwal wrote:

    "\w"  takes a letter, digit, or space character. Another alternative is to manually add a space after the digit as shown below:

     

    As far as I know, \w doesn't include the space character. It represents "word" characters, which could be a letter, digit or underscore, but not a space.

    Thursday, May 08, 2008 6:40 AM
  •  

    Thanks.. i found out how

     

    ValidationExpression="^([a-zA-Z0-9_\s\-]*)$"

     

     

    \s = Spacing

    \- =  Allowing dash -

    _ = Allow Underscore

    a-z = Small letter

    A-Z = Capital Letter

    0-9 = Numeric

     

    Thursday, May 08, 2008 7:35 AM
  •  Philippe Leybaert wrote:
     Suprotim Agarwal wrote:

    "\w"  takes a letter, digit, or space character. Another alternative is to manually add a space after the digit as shown below:

     

    As far as I know, \w doesn't include the space character. It represents "word" characters, which could be a letter, digit or underscore, but not a space.

     

    Hi,

     

    Quiet correct. Infact \d, \w and \s are shorthand for matching digits 0-9, word characters (letters and digits) and whitespace respectively.

    Sorry for the typo.

     

    HTH,
    Suprotim Agarwal

     

    Thursday, May 08, 2008 8:19 AM
    Moderator