Toolkit Lab

Guides / Developer basics

What Is a Regular Expression? A Beginner Guide

A regular expression, or regex, is a short pattern that describes text. Programmers use regex to search, check and rewrite text in code, editors and spreadsheets.

The building blocks

Flags

Flags change how the pattern works. g finds every match rather than the first, i ignores upper and lower case, and m makes ^ and $ match at each line.

Why email patterns are tricky

Email addresses have many valid forms, and a short pattern will either reject some real addresses or accept some invalid ones. A simple pattern is fine for spotting a likely address in text. For checking that an address works, send a confirmation email instead.

Try it yourself

The Regex Tester highlights each match in your text as you type. Your text is not sent to a server.