Z

What is Regular expression?

A regular expression (regex) is a pattern that describes a set of strings, used to search, match, validate and replace text. Built from literal characters and special metacharacters (like . * + ? [ ] ( )), it is supported by virtually every programming language and text editor.

Regex combines literals with metacharacters: . matches any character, */+/? are quantifiers, [...] is a character class, ( ) groups, and ^/$ anchor to start/end. For example ^\d{3}-\d{4}$ matches a 7-digit phone number.

Regexes power form validation (emails, URLs), search-and-replace, log parsing and tokenizing — but complex patterns can be hard to read, so keep them documented.

Regular expression tools

Frequently asked questions

What is regex used for?

Searching, matching, validating and replacing text — e.g. validating emails, extracting fields from logs, or find-and-replace in editors.

Are regular expressions the same in every language?

Mostly — the core syntax is shared, but flavours differ in advanced features (lookbehind, named groups, Unicode). Most follow the PCRE-style standard.