Regex

/ˈrɛdʒ.ɛks/ · Noun · Development · Origin: 1951

Definitions

  1. Regular Expression — a sequence of characters defining a search pattern, used for string matching and manipulation. Incredibly powerful and notoriously unreadable. There's a famous Jamie Zawinski quote: 'Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.'

    In plain English: A special pattern language for finding text — like a very powerful search tool where you can describe what you're looking for using special symbols instead of exact words.

Etymology

1951
Stephen Kleene describes 'regular events' (regular expressions) as a mathematical notation for pattern matching.
1968
Ken Thompson implements regex in the QED editor, bringing the concept from theory into practical computing.
1986
POSIX standardizes regex syntax. Henry Spencer writes a widely adopted regex library.
1997
Perl-compatible regular expressions (PCRE) extend the standard with lookaheads, backreferences, and other features.
2020s
Regex remains indispensable for text processing. Tools like regex101.com make the syntax more accessible to newcomers.

Origin Story

Mathematical notation that became a developer's Swiss Army knife

Regular expressions trace back to mathematician Stephen Kleene's 1956 paper on regular languages and finite automata. The theory was pure math until Ken Thompson implemented regex in the QED text editor in 1968, and then in ed and grep for Unix.

The Unix grep command (Global Regular Expression Print) brought regex to everyday computing. Henry Spencer wrote a widely-ported regex library in the 1980s, and Larry Wall embedded powerful regex support into Perl in 1987, making regex a central tool for text processing.

Today, regular expressions are both universally used and universally feared. The syntax is notoriously dense — a regex for email validation can be a page long — leading to the famous Jamie Zawinski quote: 'Some people, when confronted with a problem, think, I know, I'll use regular expressions. Now they have two problems.'

Coined by: Stephen Kleene (theory), Ken Thompson (implementation)

Context: Mathematical theory 1956, Unix implementation 1968

Fun fact: There is an annual Regex Golf competition where contestants write the shortest regex to match one list of strings but not another.

Related Terms