Python Regex Newbie- matching substrings
Daniel
danieljng at yahoo.com
Thu Jun 12 04:09:37 EDT 2003
Hi,
I would like my regex to detect that a month (any month) is in the
following line, returning the index of the start of the match:
Jun 05 14:40:26 2003 .....
So far, I've tried:
months = re.compile('(Jan)')
searchResult = months.search('abcJan')
print searchResult.start()
-Which works for just 'Jan' of course, and it correctly prints '3'.
How do I get it to work for all months?
I tried:
months = re.compile('[(Jan)(Feb)(Mar)]+')
-but that regex is too 'greedy' ie. matches too easily- I think it
matches the individual letters in each of Jan, Feb, Mar instead.
Thanks,
Daniel.
More information about the Python-list
mailing list