kent37 at tds.net
Thu Jun 9 20:19:45 CEST 2005
> I need match a regular expression, change it erasing the other strings
> after this. Just like:
> a = "I'm going send to out of space, find another race"
> And I want to match "space" instance, and erase the other.
If you mean you want to get rid of everything after 'space', this will do it:
>>> import re
>>> a = "I'm going send to out of space, find another race"
>>> re.sub('space.*', 'space', a)
"I'm going send to out of space"
You should read this and learn to make your own regexes:
More information about the Python-list