Daniel wrote: > 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: http://www.amk.ca/python/howto/regex/ Kent -- http://mail.python.org/mailman/listinfo/python-list