Compiling the Expressions

Let's figure out how we can compile the expression using re module.

We'll cover the following

The re module allows us to “compile” the expressions that we are searching for frequently. This will basically allow us to turn our expression into a SRE_Pattern object. We can then use that object in our search function.

Example of compiling using re module

Let’s use the code from earlier and modify it to use compile:

Get hands-on with 1400+ tech skills courses.