re.ASCII

The re.ASCII search modifier forces the symbols \w, \W, \b, \B, \d, \D, \s, and \S to rely on ASCII code to find text matches, rather than in Unicode.

Submitted by admin on Wed, 05/19/2021 - 08:30

re.DEBUG

The re.DEBUG search modifier displays debug information regarding the function being executed.

Submitted by admin on Wed, 05/19/2021 - 08:17

re.split

The re.split function splits the text string, considering as separator the occurrences of the regular expression pattern.

Submitted by admin on Tue, 05/18/2021 - 08:27

re.fullmatch

The re.fullmatch function checks whether the entire text string satisfies the regular expression pattern, returning the corresponding match object. If the regular expression is not found, the function returns None.

Submitted by admin on Mon, 05/17/2021 - 09:29

re.match

The re.match function checks if the regular expression pattern is satisfied at the beginning of the text string, returning the corresponding match object if it is positive. In case of no match, the function returns None.

Submitted by admin on Mon, 05/17/2021 - 08:51

re.search

The re.search function traverses the string searching for the first match of the pattern, returning the corresponding match object. In case of no match found, the function returns None.

Submitted by admin on Thu, 05/06/2021 - 07:29

re.compile

The re.compile function creates a regular expression object by compiling a regular expression pattern, which can be used as a matching pattern in the re.match, re.search, etc. functions.

The use of this function makes sense mainly when we want to reuse a search pattern throughout our code, since the previous compilation of the search pattern makes the process more efficient. For example, we can start from the following code that performs a search for the same pattern in two different texts:

Submitted by admin on Mon, 05/03/2021 - 09:37

string.whitespace

The variable string.whitespace returns the text string:

' \t\n\r\x0b\x0c'

That is, it returns all characters considered whitespace, which includes the characters space, tab, linefeed, return, formfeed, and vertical tab.

Submitted by admin on Sun, 05/02/2021 - 18:10