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

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 !!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gaurav Patil

Gaurav Patil

Machine Learning Engineer drawing insights from mathematics.