Search⌘ K
AI Features

Compilation Flags

Explore the seven compilation flags in Python 3 that alter how regular expressions behave. Understand flags like ASCII for ASCII-only matching, IGNORECASE for case-insensitivity, MULTILINE for line-specific anchors, DOTALL for matching all characters, and VERBOSE for clearer regex formatting. This lesson helps you effectively use these flags to write more precise and readable regex patterns.

There are seven compilation flags included in Python 3 that can change how our compiled pattern behaves. Let’s go over what each of them does, and then we will look at how to use a compilation flag.

re.A / re.ASCII

The ASCII flag tells Python to only match against ASCII instead of using full Unicode matching when coupled with the following escape codes: w, W, b, B, d, D, s and S. There is a re.U / re.UNICODE flag too that is for ...