As long as you can make do with str.replace()
, you should use it. It avoids all the pitfalls of regular expressions (like escaping), and is generally faster.
More Related Contents:
- Take first some character of string but if particular character will come consider that character also
- How to extract numbers from a string in Python?
- Is it worth using Python’s re.compile?
- Extract part of a regex match
- Regular expression matching a multiline block of text
- What is the difference between re.search and re.match?
- How can I do multiple substitutions using regex?
- Find shortest matches between two strings
- Matching Nested Structures With Regular Expressions in Python
- Python re.sub back reference not back referencing [duplicate]
- How to grab number after word in python
- Extract a string between double quotes
- Reuse part of a Regex pattern
- Find the indexes of all regex matches?
- RegEx Get string between two strings that has line breaks
- Python – re.findall returns unwanted result
- Why Does a Repeated Capture Group Return these Strings?
- Splitting out the output of ps using Python
- How to use regex to find all overlapping matches
- How can a recursive regexp be implemented in python?
- Python regular expression pattern * is not working as expected
- Split string at every position where an upper-case word starts
- FutureWarning: The default value of regex will change from True to False in a future version
- Why does this take so long to match? Is it a bug?
- Regex matching – why does this not match and return None?
- Python: Replace with regex
- Remove non-ASCII characters from a string using python / django
- How to strip whitespace from before but not after punctuation in python
- re.split() gives empty elements in list
- Issue with regex backreference in Python