 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Regular Expression Modifiers in Python
Regular expression literals may include an optional modifier to control various aspects of matching. The modifiers are specified as an optional flag. You can provide multiple modifiers using exclusive OR (|), as shown previously and may be represented by one of these −
| Sr.No. | Modifier & Description | 
|---|---|
| 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. | 
Advertisements
 