Regular Expression for a string
Roy Smith
roy at panix.com
Wed Nov 1 23:14:56 EST 2006
In article <1162440285.962155.325540 at f16g2000cwb.googlegroups.com>,
"Teja" <tejovathi.p at gmail.com> wrote:
> HI all,
>
> I need to write a regular experssion for a string which satisfies the
> following a criteria :
>
> 1) it should start with an alphabet
I assume you mean, "It should start with a letter"?
> 2) it can contain alphabets/digits/_ from second character
> 3) it can contain "[a-z]" or "[0-9]" at the end. but this is optional
How about: ^[a-zA-Z][a-zA-Z0-9_]*[a-z0-9]?$
Probably many variations on that theme will also work.
More information about the Python-list
mailing list