This is my first blog post and I would like to start my dev blogging journey sharing some compiled resources about regular expressions which I believe is a very powerful concept and is often found to be quite confusing or hard to interpret.
A regular expression (shortened as regex or regexp also referred to as rational expression) is a sequence of characters that define a search pattern. Usually such patterns are used by string searching algorithms for "find" or "find and replace" operations on strings, or for input validation. It is a technique developed in theoretical computer science and formal language theory. (Wikipedia).
Regex are immensely powerful and what I find so fascinating about them is that they are language agnostic and have existed since the early days of computer. Stephen Cole Kleene in the mid 1950s invented regular expressions.
My personal experience with regex hasn't been very friendly during my initial programming days and my best bet was copy pasting expressions from stack overflow and then just hope they'd work.
While there is no problem in using stack overflow answers in code and most of the time they prove to be better than self written expressions as we sometimes fail to identify some edge cases. The real problem is not being to interpret and read the regular expressions from community answers and just hoping them to work.
For someone who isn't very familiar to regex, it might look a sequence of gibberish characters and maybe a bit daunting at first. However they are quite easy if you are go over the fundamental rules and practice a bit. It will become a second nature. There are lot of great articles and tutorials to explain regex so I will not try to bore you with yet another regex101 blog post. I will rather share some great resources that I find very handy when working with regular expressions if I want to cross-check any rule.
Ultimate Regex resources
If you want to understand regular expressions in detail yet don't want to get intimidated by huge documentations, this is an ideal resource
If you are looking for regex rules cheat-sheet, this can be your go-to reference.
Below are some great websites where you can practice your regex skills. (I however most of the time prefer to use my code editor VS Code to test regex).
- A friendly regex playground. Check it out here.
- Another cool website that explains you the regex rules and supports multiple languages. Check here
- Regex101 - I like this one 😃.
Amazing video resources
Videos are my favorite ways to learn and understand stuffs. So here's some awesome regex video resources.
- How to match any pattern of text - A must watch video if you have any issues understanding regular expressions. This video also shows how you can use your code editor as your regex playground 😄
- Regex in 100 seconds - If you have an extremely short span of patience or just want to get a brief high level overview of regex, then check out this video. (It is from my favorite tech youtuber. His videos are simply ❤️)
I hope you found these resources helpful and start loving regular expressions 😄. I compiled all these resources for my personal reference. I thought it would be a good resource to share with the community as well.
Have a great one!