Reg Ex
-
How can we write a regular expression which accepts only alphabets or digits or alphanumeric(alphabets+digits)
-
-
Yes, though you may want to change it to ^[A-Za-z0-9]$ to allow lower-case letters as well. If you want to allow more than one letter or digit in a match, add a + before the $so that the expression looks like this: ^[A-Za-z0-9]+$ If you're looking for some helpful .NET regex tools, I use the free Rad Software Regular Expression Designer[^] to help build and test regular expressions.
-
How can we write a regular expression which accepts only alphabets or digits or alphanumeric(alphabets+digits)
-
Yes, though you may want to change it to ^[A-Za-z0-9]$ to allow lower-case letters as well. If you want to allow more than one letter or digit in a match, add a + before the $so that the expression looks like this: ^[A-Za-z0-9]+$ If you're looking for some helpful .NET regex tools, I use the free Rad Software Regular Expression Designer[^] to help build and test regular expressions.
-
^\w+$
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)leppie wrote:
^\w+$
As that doesn't do exactly what the OP asked for, perhaps you should have explained what it does... It allows letters, digits and underscore, i.e. it's equivalent to ^[A-Za-z0-9_]+$.
Despite everything, the person most likely to be fooling you next is yourself.
-
leppie wrote:
^\w+$
As that doesn't do exactly what the OP asked for, perhaps you should have explained what it does... It allows letters, digits and underscore, i.e. it's equivalent to ^[A-Za-z0-9_]+$.
Despite everything, the person most likely to be fooling you next is yourself.