How to Learn Regular Expressions

Regular Expressions, or RegEx, are used for searching patterns in text. For instance, a RegEx like iP(hone|ad|od)s? will find mentions of any iOS device in a document. Knowledge of Regular Expressions is essential for programmers, but they can also be an excellent skill for non-developers - people who use Microsoft Word or spend hours inside Google Spreadsheets.

RegEx in Microsoft Word

Why Learn Regular Expressions?

Regular Expressions are extremely powerful, and no less intimidating, but even a basic understanding of RegEx will save you time and make your everyday computing tasks easier.

For instance, you can quickly find & replace text that matches complex patterns in Word or Vim.

You can easily extract phone numbers and emails in spreadsheet cells using regex formulas. If you are creating a form in Google Drive, RegEx can help you define validation rules for user input. You can use RegEx in Gmail and Google Analytics too.

How do you learn Regular Expressions? Or, if you are already familiar, how do you take your RegEx skills to the next level? Of course, you will learn by doing, but some excellent tools and learning resources on the Internet will make your journey to knowing Regular Expressions more pleasant.

The Best RegEx Tools & Resources

Lea Verou’s presentation will give you a good overview of what Regular Expressions are and what you can do with them. Jeffrey Friedl’s book - Mastering Regular Expressions - is still the best-printed reference for RegEx newbies and masters. You can explore RegexOne, an interactive Codecademy-like online tutorial for learning RegEx or go here for learning the basics of pattern matching.

Highlighting all the non-English characters

RegExr is like a visual playground for Regular Expressions. First, you enter the text in one block and the RegEx in the other. Then, as you edit the RegEx, the matching strings are highlighted in the input text. You can also hover over any character literal in the RegEx to know what it does. RegEx101 is a similar tool that describes your RegEx in English as you write.

Regulex and RegExper are both open-source web apps that make it easy for you to understand and read Regular Expressions. You enter a RegEx, and the tools will create a Railroad Diagram - for a string to match, it should be able to successfully move from the left of the diagram to the left along one of the available paths.

RegEx Visualizer

Windows users can download Expresso, a free program that will help beginners write simple and complex regular expressions through a visual builder. Instead of coding the RegEx manually, you can select the components in a wizard. Reggy for Mac and RegEx Coach for Windows can also help you test regular expressions outside the browser. Also see: How to Learn Coding

Once you understand the basics, head to RegEx Golf](https://regex.alf.nu/) or play this RegEx Crossword to test your skills. Of course, like with everything else, you’ll only learn Regular Expressions by practicing, and mere reading won’t be sufficient.

Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.