Skip to content
murmot

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

  • mail.python.org

    [Tutor] string.replace() question [lookahead/lookbehind]

    I have a need to replace charachters *after* a certain point in a stringIs it because the blackslashes are already doubled up there? If so, you can write a regular expression that detects the standalone backslashes, by using 'lookbehind' and 'lookahead' assertions.

  • mail.python.org

    [Tutor] Regular expression questions

    Once again struggling with regular expressions. I have a string that look like "something_shp1". I want to replace "_shp1" by "_shp". I'm never sure if it's going to be 1, if there's going to be a number after "_shp". So I'm trying to use regular expression to perform this replacement.

  • mail.python.org

    [Tutor] Regex across multiple lines

    Can anyone tell me how to do a regex substitution across multiple lines > in HTML? > I can search for the piece of HTML I want to substitute, for instanceit works fine. Use your compiled regex for the sub(), so it will have the DOTALL flag set: html_text = p.sub(replace_string, html_text).