Glossary

Regular Expressions (Regex)

Regular expressions are a language for describing patterns in order to search, validate, and replace strings. A powerful tool, but hard to read: the expression /^[\w.-]+@[\w.-]+\.[a-z]{2,}$/i validates an email format.

Basic syntax

When not to use

Regex is not the right tool for parsing HTML/XML (use DOM parsers) or complex formats like JSON. But it is ideal for format validation and text search.

Tools

regex101.com — online testing with an explanation of every token. Indispensable when debugging complex expressions.