newbie regex

C

csselo

Hi

I want to filter some strings,but i don t know how to use compile
method.

first character must be [a-zA-z] group and others can only be digits or
letters.

like

a24354trt,Tsd1234
 
L

Leif K-Brooks

I want to filter some strings,but i don t know how to use compile
method.

Why not?
first character must be [a-zA-z] group and others can only be digits or
letters.

if re.search('^[a-zA-Z][a-zA-Z0-9]*$', foo):
print "Valid string."
else:
print "Invalid string."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,268
Messages
2,571,344
Members
48,019
Latest member
Migration_Expert

Latest Threads

Top