Software Development

What is Regular Expression?

Quick answer

A compact pattern language used to search, match, and manipulate text, such as finding email addresses or validating phone numbers.

Regular Expression, explained

A regular expression, often called regex, describes a pattern of characters. Special symbols represent ideas such as any digit, one or more repetitions, or the start of a line. Most programming languages, text editors, and databases support regular expressions.

For example, a simple pattern can match postal codes made of six digits, or find every line in a log file that contains an error code. Developers use regex for form validation, data cleaning, search and replace, and parsing structured text. Regular expressions are powerful but notoriously hard to read, and complex patterns can be slow or behave unexpectedly. Some poorly written patterns can even be exploited to overload a server. For complicated formats such as HTML or full email validation, dedicated parsers are usually safer.

Related terms

Guides that mention Regular Expression