Pythex

Yesterday I used pythex to do some regex testing. I learned that I can use the findall method of the re python library to find repeating matches.
e.g.

import re
expr = '([0-9]+?);'
line = '1999;2000;2001;2002;'
re.findall(expr,line)

The result will be:
[‘1999’, ‘2000’, ‘2001’, ‘2002’]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s