[Tutor] Python Regex References

Devyn Collier Johnson devyncjohnson at gmail.com
Thu Dec 20 04:16:03 CET 2012


    I am trying to convert the SED code below to Python3.3. How do I
reference the value of the first and second wildcards so that I can put
the variable values in the "replace" portion of the code?

SED (this works):
export DATA=$(echo "$DATA" | sed -r -e "s|^<substitute find=\"(.*)\"
replace=\"(.*)\"/> $|\1(>=>)\2|gI")

Python3.3 (attempted):
DATA = re.sub('^<substitute find=\".*\" replace=\".*\"/>$', '\1(>=>)\2',
DATA, flags=re.I)


Thank you,

DevynCJohnson at Gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121220/bea9ca5e/attachment.html>


More information about the Tutor mailing list