Regular Expression for a string

Teja tejovathi.p at gmail.com
Thu Nov 2 05:28:51 CET 2006


James Stroud wrote:

> Teja 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
> > 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
> >
> >  can any one please help me out.... pls....
> >
> >
> > Teja.P
> >
>
> This is as general as could be constructed given your vague requirements:
>
> "[a-zA-Z][a-zA-Z0-9_]+"
>
> You may need to provide examples.
>
> James
>
>
>
> --
> James Stroud
> UCLA-DOE Institute for Genomics and Proteomics
> Box 951570
> Los Angeles, CA 90095
>
> http://www.jamesstroud.com/

Thnks James for ur quick reply.....
Here is what I want actually

Some examples

string1
string_1
string1[0]
string_1_str[a]
STRING_1_[2]
STRING_1_str[a][1][2]

etc
etc

I need a regular expression for such strings




More information about the Python-list mailing list