Ezio Melotti <[email protected]> added the comment: You forgot to use raw strings: >>> text = "The cat ate the rat." >>> print("before: %s" % text) before: The cat ate the rat. >>> text = re.sub("(\w+) ate the (\w+)", r"\2 ate the \1", text) >>> print("after : %s" % text) after : The rat ate the cat. >>>
(Maybe you should reconsider writing yet another tutorial about regular expressions, and possibly submit patches to improve the official regex howto if you think it's not good enough.) ---------- assignee: -> ezio.melotti resolution: -> invalid stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker <[email protected]> <http://bugs.python.org/issue14221> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
