ENES

Regex

A compact pattern language for finding and checking pieces of text.

A regex pattern for dates is laid over a paragraph of text, and the two dates in it are highlighted as matches

A regex (regular expression) is a short pattern that describes a shape of text, so a program can find every piece of text with that shape. Instead of searching for one exact word, you describe what you want: "four digits, a dash, two digits". In regex that is written \d{4}-\d{2}, where \d means any digit and {4} means exactly four of the previous thing.

Regexes are everywhere text is processed. A signup form uses one to check that an email looks like an email. A spreadsheet or code editor uses them for powerful find-and-replace, like turning every date from 2026-10-17 into 17/10/2026 in one go. Programmers use them to pull order numbers out of emails, clean up messy data or scan logs for errors. Almost every programming language and many text tools support them.

Their power comes with a reputation for being hard to read. A pattern like ^[\w.+-]+@[\w-]+\.[\w.]+$ is dense, and small mistakes match too much or too little. Good practice is to keep patterns simple, test them against real examples with tools like regex101, and not use them for jobs they handle badly, such as fully parsing HTML.

Keep in mind

Go deeper

Related terms

More in Software