Email the Author
You can use this page to email Zsolt Nagy about Understanding Regular Expressions.
About the Book
Exploration is not enough
Many of us default to a journey of discovery when it comes to playing around with something we don’t know well. With regular expressions, the task seems just too easy: we just have to create a short expression, right? Well, often times, this point of view is very wrong.
Trial and error often times takes more time than getting the pain handled, and getting lack of knowledge cured. Yet, most developers do this over and over again. This is because learning regular expressions seems to be too hard at first glance. Therefore, my mission is to show you that
- learning regular expressions is a lot easier than you thought,
- knowing regular expressions is fun,
- knowing regular expressions is very beneficial in many areas of your software developer career.
You can easily master regular expressions to the extent that they will do exactly what you intended them to do. This mastery comes through understanding the right theory, and a lot of practice.
Why are regular expressions important?
In today’s world, we have to deal with processing a lot of data. Accessing data is not the main problem. Filtering data is. Regular expressions provide you with one type of filter that you can use to extract data relevant to you from the big chunks of data available to you.
For instance, suppose you have an XML file containing four gigabytes of data on movies. Regular expressions make it possible to query this XML text so that you can find all movies that are filmed in Budapest in 2016 for instance.
Regular expressions are a must have for software developers.
In frontend development, we often validate input using regular expressions. Many small features are also easier with regular expressions, such as splitting strings, parsing input, matching patterns.
In backend and data science, we often search, replace, and process data using regular expressions.
In IT infrastructure, regular expressions have many use cases in Linux. VIM and EMACS also come with regex support for finding commands, as well as editing text files.
Regular expressions are everywhere. These skills come handy for you in your IT engineering career.
Why Regular Expressions are Widely Misunderstood
Regular expressions are widely misunderstood. People who taught you regular expressions either come from a theoretical point of view using formal languages and computer science, or they developed their understanding using trial and error.
Whenever you hear that regular expressions are declarative, run from that tutorial or blog as far as you can. A regex is an imperative language. It’s like JavaScript, except that the syntax is different. If you want to understand regexes as declarative, chances are, you will fail.
According to the theoretical definition above, regexes specify a search pattern. Although this is a true statement, it is easy to misinterpret it, because we are not specifying a declarative structure. In the real world, we specify a sequence of instructions acting like a function in an imperative programming language. We use commands, loops, we pass arguments to our regex, we may pass arguments around inside our regex, we return a result, and we may even cause side-effects.
If you have dealt with at least one programming language in your life, chances are, you know almost everything to understand regular expressions. You are just not yet proficient in this weird language describing regular expressions. As soon as you familiarize yourself with this weird language, everything will fall into place.
About the Author
I am Zsolt Nagy, founder of zsoltnagy.eu, a blog on writing maintainable web applications, and devcareermastery.com, a career blog on designing a fulfilling career.
I am the author of two other Leanpub books:
- ES6 in Practice - The Complete Developer's Guide, and
- The Developer's Edge - How to Double Your Career Speed with Soft-Skills.
Launch Offer
If you are still reading this page, you might wonder, when will now be a good time to master regular expressions?
During the launch period, prices are still low. Grab the book before prices are raised.
If you are interested in an upgrade, and you happen to be a JavaScript developer, I am currently shooting a JavaScript course on regular expression. During the launch offer, you can buy this video course at a discount. Be aware though that the course is currently incomplete. I will add videos to the course on a regular basis during the next months.
About the Author
There were times when I was not conscious about my career choices at all. During my university years, I was far too busy with my studies and with an EU funded research project. While writing my thesis, I earned more than the average starting salary of MsC graduates in my country. When things are going so well early in your career, believe me, you won't start thinking about the next step.
This proved to be a mistake. I started my job interviews just a couple of months before graduation. I only had a resume, and some references on a research project. I also happened to be a below average communicator.
Even though I could choose from many options, none of those options seemed to be too lucrative. Having realized my awkward position, I chose the path of maximum responsibility, and joined a tech startup. The trade-off for excellent working conditions was bad pay. I kept on telling myself that I deserved more. Truth is, I deserved exactly the amount that I was able to negotiate. Back then, I didn't accept these facts, and was waiting for others to give me a raise whenever they praised me. A simple strategy destined to fail.
Software developers are in high demand, as there is a shortage of good professionals all over the world. I asked myself, come excellent developers still waste their talent by working for companies that don't respect them financially or professionally?
Throughout the last ten years, I have been continuously improving my tech skills as well as my soft skills. These improvements have enabled me to assume Team Lead and Technical Lead positions. Above all, these skills have enabled me to work with the companies I want. I encourage you to do the same.
For more, visit my website, devcareermastery.com.
My technical blog is about developing maintainable web applications using JavaScript. Read it on zsoltnagy.eu