What is a regular expression (Regex)?
A structured sequence of characters defining a formal search pattern utilized by string-matching engines for parsing, validation, and replacement.
Micro-Technology Solutions
Write a regular expression and see matches, the explanation and copy-ready code, all live.
Test string
Step-by-step explanation
Type a regular expression to get started.
Copy-ready code
Pick your language and copy the snippet.
const regex = //g;
const isMatch = regex.test(input);
const allMatches = [...input.matchAll(new RegExp(regex.source, regex.flags.includes("g") ? regex.flags : regex.flags + "g"))];DFA vs NFA engines, ReDoS prevention, capture groups, and lookaround assertions.
JavaScript and Python rely on NFA engines allowing backreferences and lookarounds, which introduces potential backtracking overhead compared to linear DFA engines.
Nested quantifiers like `(a+)+$` cause exponential step explosions when failing near the end of strings, locking CPU threads in single-threaded environments.
Non-capturing groups `(?:...)` cluster subexpressions without allocating match slots or capturing overhead, boosting throughput in high-volume parsing.
Lookaheads and lookbehinds assert surrounding context without consuming characters, essential for multi-rule password policies and currency parsing.
Step-by-step fixes for ReDoS locks, JavaScript lastIndex bugs, string escaping, and greedy matching.
Zawinski's iconic quote, the Unix grep origin, and 1951 neural network foundations.
"Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems." Became software engineering's most famous quip.
Mathematician Stephen Kleene invented regular algebra to mathematically describe firing patterns in biological neural circuits.
Ken Thompson added regex to Unix `ed`. The command `g/re/p` (Global Regular Expression Print) became the standalone utility `grep`.
Written by Philip Hazel in 1997, PCRE powers Apache, Nginx, PHP, and hundreds of mission-critical systems worldwide.
Learn the fundamental concepts, protocols, and technical terminology of this tool.
A structured sequence of characters defining a formal search pattern utilized by string-matching engines for parsing, validation, and replacement.
An algorithmic security flaw where ambiguous nested quantifiers trigger exponential evaluation loops, freezing host CPU threads in denial-of-service.
Subpatterns enclosed in parentheses `(...)` isolating matched token substrings for programmatic extraction and backreference replacement.
Zero-width pattern assertions matching a character sequence only if followed or preceded by another specific pattern without consuming string length.