
May 21st, 2004, 09:20 AM
|
|
Contributing User
|
|
Join Date: Feb 2004
Location: London, England
|
|
There is a tutorial at http://www.amk.ca/python/howto/regex/.
The book 'Text Processing in Python' by David Mertz has a chapter on regular expressions. You can find a web copy of the book at http://gnosis.cx/TPiP/.
In answer to your second question:
Code:
>>> import re
>>> s = " What a nice day guys. hello it's me Omega "
>>> match = re.search(r'hello(.*)', s)
>>> match.group(1)
" it's me Omega "
The regular expression "hello(.*)" will match the "hello", then assign all the text after it to a group, which can then be extracted from the match object.
Dave - The Developers' Coach
Last edited by DevCoach : May 21st, 2004 at 09:23 AM.
|