Skip to content
murmot

Results for “python string replace regular expression code site:mail.python.org”

  • mail.python.org

    [Tutor] Search and Replace

    Why use regular expressions, when there is a perfectly good >string.replace() function that does exactly what you want? >I am thinking of rewriting and expanding this to include a mode argument, with modes 0,1,2 = string replacement, regex, compiled regex object. >

  • mail.python.org

    [Python-Dev] New regex syntax? (was: Some questions about...)

    I'd say both regular expressions and the corresponding python code can be pretty incomprehensible.I've stumbled upon both 100 char regexes and 25 line python string manipulation snippets - both variants taking a while to figure out what they do.

  • mail.python.org

    [Tutor] Multiple regex replacements, lists and for.

    You should make your Python regex more like sed. re.sub() always returns a string, either changed or unchanged. So you can "pipe" the two necessary re.sub() onto each other, like you do for sed: re.sub(replacement, replacement, re.sub(replacement, replacement, string).