tags:

views:

158

answers:

3

The above expression is working fine. this expression means first leter should start with characters only not a digit, remaining letters alphanumarics. but it not allow when i give underscore like "s_sasi" it is giving error message can u help me i want to allow the underscore also in that expression thank u

+7  A: 
^[A-Za-z][A-Za-z0-9_]*$

or better

^[A-Za-z][\w]*$
Martin Hohenberg
Hi Martin Hohenberg the expression is not accetping in the regular expression it is giving error thank you for response
Surya sasidhar
which one gives the error?
Martin Hohenberg
@Surya - make sure you escape the \ sign: try ^[A-Za-z][\\w]*$, or `@"^[A-Za-z][\w]*$"`
Kobi
Ya Martin second expression working fine thank you
Surya sasidhar
ok first one also working fine thank you dude
Surya sasidhar
`[\w]` is redundant : use `^[a-zA-Z]\w*$`
Amarghosh
+2  A: 

Have you tried ^[A-Za-z][_A-Za-z0-9]*$ ?

Traveling Tech Guy
+2  A: 
^[A-Za-z][A-Za-z0-9_]*$
x2