regular expressions

Text search patterns

Regular expressions are patterns used to match sequences of characters in text.

They form a kind of search language, combining literal characters with special symbols to find, validate, or manipulate strings: The regex matched all email addresses in the document.

Often shortened to regex or regexp.

Learning regular expressions means mastering cryptic syntax—brackets, asterisks, question marks—that looks impenetrable until it clicks: Her regex replaced every phone number with XXX-XXX-XXXX.

tools

grep

Text pattern search utility

  • PerlText-processing scripting language
  • PythonLarge nonvenomous squeezer
  • command lineText-based computer interface

JavaScript · Ruby · Java · vim · PowerShell · lex · flex

syntax

pattern

Recurring arrangement or template

grouping · lookahead · escape · literal · greedy · lazy · boundary · modifier · flag · wildcard

applications

text processing

Manipulating written digital content

spam filtering · find and replace · lexical analysis

operations

match

Game between opponents

extract · parse · filter · validate · split · substitute · capture · test · compile · tokenize

learning

complexity

State of being complicated

debugging · readability · documentation · cheat sheet · tutorial · testing · trial and error · escaping · edge cases · backtracking

Opposites
pattern matching approach

regular expressionsexact match

Perfect one-to-one correspondence

search sophistication

regular expressionssimple search

Basic query without refinements

keyword search

formal language complexity

regular expressionsTuring machines

Formal models of computation

Family

regular, regulate, irregular, regulation, expressions, regulated, irregularity, regulating, regular expression

Familiarity
Top 500,000
Profile
Used worldwide · Timeless · Abstract · Rated G