|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I was wondering if anyone knows a goods tutorial on using regular expressions. I have gone through the phython manual and tutorial in the supplied documentation but it is not detailed. Also how would I get everthig after the "hello" in this string using the regular expersion module?
" What a nice day guys. hello it's me Omega " thank you |
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > regular expression |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|