Tutorial 3: Regular Expressions in Python — Using regex metacharacters ‘ ? * + . ’

Gaurav Patil
2 min readSep 26, 2021

--

Photo by Ilya Pavlov on Unsplash

Till now, we have covered:

Why do we use ‘r’- raw string ?

Tutorial 1- Finding a particular word

Tutorial 2- Finding individual digits or alphabets or other characters

When I started learning coding , I found that concepts are better understood when used in variety of examples. That’s why I am giving many examples for each topic enlisted below. Click on the topic to navigate directly .

1. metacharacter ‘ ? ’ — to match zero or one repetition of the preceding regex pattern

2. metacharacter ‘ * ‘ — to match zero or more repetitions of the preceding regex pattern

3. metacharacter ‘ + ’ — to match 1 or more repetitions of the preceding regex pattern

4. metacharacter ‘ . ‘ (dot) — to match any character except a newline.

1. metacharacter ‘ ? ’

This is used to match zero or one repetition of the preceding regex pattern

2. metacharacter ‘ * ‘

This is used to match zero or more repetitions of the preceding regex pattern

3. metacharacter ‘ + ’

This is used to match 1 or more repetitions of the preceding regex pattern

4. metacharacter ‘ . ‘ (dot)

This is used to match any character except a newline.

Congratulations !! In this tutorial we covered few basic metacharacters used in regex.

This is real fun. Take a deep breathe and move to the next tutorial.

Happy learning !!!

--

--

Gaurav Patil
Gaurav Patil

Written by Gaurav Patil

Machine Learning Engineer drawing insights from mathematics.

Responses (1)