delete comments with re
laurent8 at sxb.bsf.alcatel.fr
laurent8 at sxb.bsf.alcatel.fr
Tue Mar 7 09:32:33 EST 2000
Hi,
Given this string (t)
>>> t='a=b; /* comment */ o=1; /** ** * **dgbgfg* ** ** */ j=1; /* fgd
*/ class foobar {}'
I want to have this result :
t='a=b; o=1; j=1; class foobar {}'
that is to say, I want to del every /* */ sequence.
with this regular expression I've got
>>> r="/\*.*\*/"
>>> re.sub(r,'',t)
'a=b; class foobar {}'
so I tried
>>> r="/\*([^\*][^/])*\*/"
and then this is not the expected result
>>> re.sub(r,'',t)
'a=b; /* comment */ o=1; /** ** * **dgbgfg* ** ** */ j=1; /* fgd */
class foobar {}'
somebody has an idea ???
thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list