About 236,000 results
Open links in new tab
  1. python .replace () regex - Stack Overflow

    118 In order to replace text using regular expression use the re.sub function: sub (pattern, repl, string [, count, flags]) It will replace non-everlaping instances of pattern by the text passed as string.

  2. regex - Python string.replace regular expression - Stack Overflow

    I am using a line replace function posted previously to replace the line which uses Python's string.replace(pattern, sub). The regular expression that I'm using works for instance in vim but …

  3. Python replace string pattern with output of function

    Sep 26, 2012 · 77 I have a string in Python, say The quick @red fox jumps over the @lame brown dog. I'm trying to replace each of the words that begin with @ with the output of a function that takes the …

  4. Regex replace (in Python) - a simpler way? - Stack Overflow

    Regex replace (in Python) - a simpler way? Asked 16 years, 11 months ago Modified 12 years, 8 months ago Viewed 107k times

  5. python - How can I do multiple substitutions using regex ... - Stack ...

    The answer proposed by @nhahtdh is valid, but I would argue less pythonic than the canonical example, which uses code less opaque than his regex manipulations and takes advantage of python's built-in …

  6. Speed up millions of regex replacements in Python 3

    Mar 15, 2017 · Speed up millions of regex replacements in Python 3 Asked 8 years, 10 months ago Modified 2 years, 6 months ago Viewed 94k times

  7. python - Replace all occurrences that match regular expression - Stack ...

    Jul 2, 2016 · In Python, match searches for a match at the start of a string, it does not require a full string match. re.sub finds all non-overlapping sequences matching the pattern and replaces them.

  8. regex - Use Python's string.replace vs re.sub - Stack Overflow

    Apr 14, 2011 · For Python 2.5, 2.6, should I be using string.replace or re.sub for basic text replacements? In PHP, this was explicitly stated but I can't find a similar note for Python.

  9. python - re.sub replace with matched content - Stack Overflow

    7 For the replacement portion, Python uses \1 the way sed and vi do, not $1 the way Perl, Java, and Javascript (amongst others) do. Furthermore, because \1 interpolates in regular strings as the …

  10. Python Regex instantly replace groups - Stack Overflow

    This is Python's regex substitution (replace) function. The replacement string can be filled with so-called backreferences (backslash, group number) which are replaced with what was matched by the …