Member-only story
Everything You Need To Know About Regular Expressions in Python
How to be a wizard of Regex

Dear coders and software development aspirants. Lets us face a fact here: Regex is scary. Damn scary. Why? I hear you ask.
Because it is a series of characters and symbols that (to untrained eyes) can appear as intimidating as trying to read signboards at a foreign language street. It kind of makes the term “Regular Expressions” or Regex in short, ironic.
I avoided regex at all costs, and for far too long than I would like to admit. But one day I decided it was high time that I learned to use it.
Regex is an extremely important part of a programmer’s journey. It is a tool you need to have in your utility belt, and it can rescue you from the painfully long time spent writing an unnecessarily long code.
So, I dived right into the mysterious world of regex. I had expected it to be difficult, but once I understood the basic concepts, the way forward was quite simple.
I realized that it was just like learning any other language: once you understand the words and the grammar, stringing together sentences becomes second nature.
In the most basic sense, regular expressions are a series of characters that search for a pattern. These character sequences are instances of Regular language and are most commonly used for text parsing or any kind of string input validation.
Imagine a physical cardboard sheet with certain shapes cut out of it. Only the shapes that exactly match the cut-outs can pass through. The cardboard sheet is then equivalent to a regex string.

How could a regex search pattern for this look like?
Regex: circle|triangle|hexagon
Input statement: The three incoming shapes are circle, triangle and rectangle.
The regex engine will only match the words circle
and triangle
. You can also try it out here.
Simple isn't it!