RegExp editor
Write a regular expression — matches highlight in real time, and every token in the pattern is explained below. Plus a library of ready-made expressions for email, phones, dates, IPs and other common cases.
01
Editor and highlighting
02
Token-by-token breakdown
every character in the pattern — with its purpose03
Library of ready-made expressions
click an example — pattern and test text will loadEmail
/[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}/g
Телефон РФ
/(?:\+7|8)[\s\-]?\(?\d{3}\)?[\s\-]?\d{3}[\s\-]?\d{2}[\s\-]?\d{2}/g
Телефон международный
/\+[1-9]\d{0,2}[\s\-]?\(?\d{1,4}\)?[\s\-]?\d{1,4}[\s\-]?\d{1,9}/g
URL
/https?:\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/gi
04
About regular expressions
RegExp syntax
JS flavour/pattern/flags · new RegExp('p', 'g')
Regular expressions — a mini-language for pattern search and replace. JavaScript uses its own dialect (PCRE-inspired). Key parts: anchors (^ $ \b), classes (\d \w \s . [ ]), quantifiers (* + ? {n,m}), groups (( ) (?: )), alternation (|).
Flags
gimsuyg · global · i · ignore case · m · multiline
g — find all matches, not just the first. i — case-insensitive. m — ^ and $ work per line. s — dot matches \n. u — Unicode. y — sticky (only from lastIndex). Flags combine: /.../gim.
Greedy vs lazy
Backtracking.* — greedy · .*? — lazy
Quantifiers are greedy by default — they grab as much as possible. Add ? to make them lazy — they take the minimum. Classic example: .* in /<.*>/ on '<a><b>' captures '<a><b>', while .*? — only '<a>'. For parsing HTML use a proper parser.
Watch performance
ReDoS(a+)+ on 'aaaaX' — exponential
Some patterns can hang on millions of backtracking iterations (a ReDoS attack). Nested quantifiers like (a+)+ or (a|a)* are dangerous. Write atomic patterns and test on long inputs. In safety-critical places use RE2 (Go, Google) which has no backtracking.