How to know what re.sub took?

Per Kistler kistler at gmx.net
Tue Apr 11 16:14:38 EDT 2000


Hello

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