How to know what re.sub took?

Per Kistler kistler at
Tue Apr 11 22:14:38 CEST 2000


How to know what has been substituted away, if one does something like:

 >>> import re
 >>> rex = re.compile(r"(hans|fred|simon)")
 >>> st = "max hans bill"
 >>> st2 = rex.sub("",st)
 >>> st2
'max  bill'

It took "hans" away, but how can I learn this automatically?

Thanks, Per.

More information about the Python-list mailing list