Regex with Python

Tram Ho

As in the previous article, I introduced some basic regex concepts. In this article I will introduce to you the use of regex in the programming language, here is python.

1. Library

Regex uses the re module to work in python, this module is a built-in library in python, you don’t need to install it to use it.

2. Some functions

2.1. re.match


Match pattern with string with arbitrary flags. Here is the syntax for this function.

The re.match function returns 1 object if the match succeeds and returns None if it fails



This function does a string search on 1 string and returns the matched values

2.3. re.split


re.split returns the characters separated by the pattern

Share the news now

Source : Viblo