Help with Regular Expressions

Harlin Seritt harlinseritt at yahoo.com
Wed Aug 10 03:04:39 EDT 2005


I have been looking at the Python re module and have been trying to
make sense of a simple function that I'd like to do. However, no amount
of reading or googling has helped me with this. Forgive my
stone-headedness. I have done this with .NET and Java in the past but
damn if I can't get it done with Python for some reason. As such I am
sure it is something even simpler.

I am trying to find some matches and have them put into a list when
processing is done. I'll use a simple example like email addresses.

My input is the following:
wordList = ['myname1', 'myname2 at domain.tld', 'myname3 at domain.tld',
'myname4 at domain', 'myname5 at domain.tldx']

My regular expression would be something like '\w\@\w\.\w' (I realize
it could and should be more detailed but that's not the point for now).

I would like to find out how to output the matches for this expression
of my 'wordList' into a neat list variable. How do I get this done?

Thanks,

Harlin Seritt




More information about the Python-list mailing list