You have to mark the string as a raw string, due to the \
in there, by putting an r
in front of the regex:
m = re.match(r"<(.*)>phone</\1>", "<bar>phone</bar>")
Related Contents:
- How to use a variable inside a regular expression?
- Regular expression to return text between parenthesis
- Regex matching between two strings?
- How to match any string from a list of strings in regular expressions in python?
- Python regex for unicode capitalized words
- Python TypeError on regex [duplicate]
- How to extract numbers from a string in Python?
- How do I type hint a method with the type of the enclosing class?
- How do you fix “runtimeError: package fails to pass a sanity check” for numpy and pandas?
- Split string on whitespace in Python [duplicate]
- Fast punctuation removal with pandas
- Normalizing Unicode
- How to install python3 version of package via pip on Ubuntu?
- Why does the print function return None?
- Reading file using relative path in python project
- FutureWarning: elementwise comparison failed; returning scalar, but in the future will perform elementwise comparison
- How can I intercept calls to python’s “magic” methods in new style classes?
- Django – No such table: main.auth_user__old
- What is the good python3 equivalent for auto tuple unpacking in lambda?
- Python sockets error TypeError: a bytes-like object is required, not ‘str’ with send function
- Regular Expressions: Search in list
- Generate a random letter in Python
- Difference between static STATIC_URL and STATIC_ROOT on Django
- Upload Image using POST form data in Python-requests
- Why is adding attributes to an already instantiated object allowed?
- How can I generate a list of consecutive numbers?
- Argparse with required subparser
- remove unicode emoji using re in python
- How to print multiple lines of text with Python
- Python 3.4.0 with MySQL database
- How to prevent BrokenPipeError when doing a flush in Python?
- How do I convert a string into an f-string?
- Using variables in the format() function in Python
- Disable hash randomization from within python program
- What’s the difference between str.isdigit(), isnumeric() and isdecimal() in Python?
- TypeError: ‘int’ object is not subscriptable – Trying To Create A Graph
- Printing result of the zip() function in Python 3 gives “zip object at ” [duplicate]
- How can I use newline ‘\n’ in an f-string to format output?
- Error while downloading the requirements using pip install (setup command: use_2to3 is invalid.)
- How to use re to find consecutive, repeated chars
- Python 3.4 :ImportError: no module named win32api
- Lazy evaluation in Python
- Trying to fix tkinter GUI freeze-ups (using threads)
- pip no longer working after update error ‘module’ object is not callable
- Remove NaN ‘Cells’ without dropping the entire ROW (Pandas,Python3)
- Kivy error, [CRITICAL] [Text ] unable to find any valuable text provider (python 3.6.1) (windows 10)
- How to test Python 3.4 asyncio code?
- Class Based Views VS Function Based Views
- Namespace vs regular package
- Converting string to tuple without splitting characters