Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does python's "re.compile" do?

Tags:

python

regex

When you run re.match for the original string and the string that was passed through re.compile, how is the latter different? What happened to the string that was passed through re.compile?

like image 825
mango Avatar asked Dec 04 '13 21:12

mango


People also ask

What does mean by re compile?

to compile (a set of machine instructions) again or in a different way. Governments will be able to look at the source code but will not be able to alter or recompile the software. 2. to compile (a list, text, etc) again or in a different way.

What is re compile R?

According to this the "r" in pythons re. compile(r' pattern flags') refers the raw string notation : The solution is to use Python's raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with 'r'.

What is the use of re module?

The re module provides a set of powerful regular expression facilities, which allows you to quickly check whether a given string matches a given pattern (using the match function), or contains such a pattern (using the search function).

WHAT IS RE pattern in Python?

A RegEx, or Regular Expression, is a sequence of characters that forms a search pattern. RegEx can be used to check if a string contains the specified search pattern.


1 Answers

It compiles a regex into a regex object. Take a look at the docs for more info.

like image 102
JonathanV Avatar answered Oct 08 '22 01:10

JonathanV