What is Regular Expression (1)

Mukerong
Mukerong
Feb 25, 2017 · 2 min read
Regex Rocks!
Regex Rocks!
Regex Rocks!

Based on the Definition on Wiki,

A regular expression is a sequence of characters that define a search pattern in theoretical computer science and formal language.

So what does it exactly mean? Based on my understanding, I think regular expression is a very simple language that can help with search/find function. For example, if you want to find a movie called “zootopia” saved in your computer, but all you forget the name, and all you can remember is “zoo something with ‘ia’ at then end ”. What you are going to do? You may start to search “zoo” in your computer, but you may have hundreds or thousands of files saved with “zoo” in the name. Are there any better way to find it?

Luckily, regular expression (Regex) is here to help. It can help you search whatever pattern you want to use. In the example above, you can simply use ^zoo\w*ia$ to match the pattern and find the movie you want. Don’t worry if you do not understand what the thing I just wrote mean. It was nonsense to me several week ago. I will show you in the following ones to help you understand the awesome regex.

Before I start, I want to provide some documentations and website that can help you understand and practice regex. There are many other resources you can use, such as Codecademy, but the following three are extremely useful for me.

  • Regex Documentation provides the comprehensive documentation you can refer to help you understand all aspects of regex.
  • RegExr is an awesome website that summarize the most important information about regex. It has cheatsheet you can refer to, and have samples that can help you decide whether your regex is correct.
  • Hackerrank has very good practice for people check how their knowledge. It also has lots of other languages practice, such as SQL and Python.

Written by

Mukerong

Learn to fail or fail to learn

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade