re documentation error
Carlos Gaston Alvarez
cgaston at moonqzie.com
Mon Sep 17 06:44:26 EDT 2001
It seems like an error. If it is not, someone explain it to me please (and
update the doc).
Empty matches are replaced only when not they're not adjacent to a previous
match.
>>> p = re.compile('x*')
>>> p.sub('-', 'abxd')
'-a-b-d-'
I would expect the result to be.
'abd'
If the '-' is representing no char, an empty string (as the text says) then
I would like it to say
>>> p = re.compile('x*')
>>> p.sub('', 'abxd')
'abd'
Which is an example that does teachs nothing new.
is - an special char of re for representing nothing?
Dont think so.
Chau,
Gaston
More information about the Python-list
mailing list