Lucas Bernard
Lucas Bernard

Reputation:

Regex in python

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!

Upvotes: 0

Views: 532

Answers (2)

SilentGhost
SilentGhost

Reputation: 319551

this?

^[A-Za-z0-9_.][A-Za-z0-9_ ]{0,31}$

Upvotes: 2

seize
seize

Reputation: 853

From 0 to 32 chars:

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

Upvotes: 0

Related Questions