
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How regular expression modifiers work in Python?
Regular expression literals may include an optional modifier to control different aspects of matching. The modifiers are specified as an optional flag. You can provide multiple modifiers using exclusive OR (|), and may be represented by one of these −
The following is a list of different re modifiers and their functions.
1. re.I
Performs case-insensitive matching.
2. re.L
Interprets words according to the current locale. This interpretation affects the alphabetic group (\w and \W), as well as word boundary behavior(\b and \B).
3 re.M
Makes $ match the end of a line (not just the end of the string) and makes ^ match the start of any line (not just the start of the string).
4 re.S
Makes a period (dot) match any character, including a newline.
5 re.U
Interprets letters according to the Unicode character set. This flag affects the behavior of \w, \W, \b, \B.
6 re.X
Permits "cuter" regular expression syntax. It ignores whitespace (except inside a set [] or when escaped by a backslash) and treats unescaped # as a comment marker.
- Related Questions & Answers
- Regular Expression Modifiers in Python
- How regular expression alternatives work in Python?
- How regular expression anchors work in Python?
- How does [\d+] regular expression work in Python?
- How does \B regular expression work in Python?
- Explain JavaScript Regular Expression modifiers with examples
- How does BackReference work with Python Regular Expression with Unicode?
- Regular Expression Examples in Python
- Regular Expression Patterns in Python
- Regular Expression Matching in Python
- How regular expression grouping works in Python?
- How do backslashes work in Python Regular Expressions?
- Regular Expression in Python with Examples?
- How regular expression back references works in Python?
- How to use wildcard in Python regular expression?