0

I'm trying to use regular expression right now and I'm really confuse. I want to make some validation with this regular expression :

^[A-Za-z0-9_.][A-Za-z0-9_ ]*

I want to make it so there is a limit of character (32) and I want to "match" all the string.

ex:

string : ".hello hello" -this should work

string : ".hello hello /.." -This should be rejected because of the /..

Thanks!

2 Answers 2

2

this?

^[A-Za-z0-9_.][A-Za-z0-9_ ]{0,31}$
Sign up to request clarification or add additional context in comments.

1 Comment

I'd start a debate about whether the "match all the string" requirement means that \Z should be used instead of $, but it's way past my bed-time, so I won't :-)
0

From 0 to 32 chars:

^[\w\d_.]{0,32}$

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.