text processing problem

Maurice LING mauriceling at acm.org
Thu Apr 7 20:26:07 EDT 2005


Matt wrote:
> 
> 
> Try this:
> import re
> my_expr = re.compile(r'(\w+) (\(\1\))')
> s = "this is (is) a test"
> print my_expr.sub(r'\1', s)
> #prints 'this is a test'
> 
> M@
> 

Thank you Matt. It works out well. The only think that gives it problem 
is in events as "there  (there)", where between the word and the same 
bracketted word is more than one whitespaces...

Cheers
Maurice



More information about the Python-list mailing list