ID EN
Regular Expression

compile

Python 3.11

Compile a regular expression pattern into a regular expression object, which can be used for matching using its match(), search() and other methods, described below.

Syntax

PYTHON
re.compile(pattern, flags=0)

Examples

Example 1
PYTHON
prog = re.compile(pattern)
result = prog.match(string)
Example 2
PYTHON
result = re.match(pattern, string)

See Also

regular expression object match() search() flags re.compile() re.compile()