For Regular Expressions Check out this link

http://www.amk.ca/python/howto/regex/