re.sub and named groups
manu3d at gmail.com
Wed Feb 4 17:51:41 CET 2009
I'm having a ball with the power of regular expression but I stumbled
on something I don't quite understand:
theOriginalString = "spam:(?P<first>.*) ham:(?P<second>.*)"
aReplacementPattern = "\(\?P<first>.*\)"
re.sub(aReplacementPattern , aReplacementString, theOriginalString)
results in :
instead, I was expecting:
Why is that?
Thanks for your help!
More information about the Python-list