Development
Regex syntax reference
Look up JavaScript regex quantifiers, groups, assertions, and flags.
Ready when you are
01
Add your contentPaste text or try a sample
02
Choose an actionClear options. Predictable results.
03
Take it with youCopy, download and carry on
Using this tool
Search JavaScript regex syntax entries to check their purpose before writing a pattern.
Actions: Process
Example
Search lookahead to view lookahead assertion entries; reference lookup does not run a regex.
Example action and settings
Action: Process
Input / action
lookahead
Result / expected behavior
(?=abc) Positive lookahead (?!abc) Negative lookahead
Scope and limitations
- This is a static JavaScript syntax reference, not coverage of every other regex engine.
Common mistakes
- Keyword search does not interpret the query as a regex filter; use the regex lab for actual matches.
Related tools
Privacy and browser support
Input is processed in this browser. Do not use real keys or active sensitive credentials as demonstration data. Device features require browser support and your permission.
JavaScript regular expression reference
JavaScript syntax, not every regex dialect. Unicode features and lookbehind depend on browser support. Flags u and v cannot be combined.
| Syntax | Meaning |
|---|---|
| abc | Literal text |
| . | Any character (except line terminators by default) |
| \d / \D | Digit / non-digit |
| \w / \W | Word character / non-word character |
| \s / \S | Whitespace / non-whitespace |
| [abc] | Character set |
| [^abc] | Negated character set |
| [a-z] | Character range |
| ^ / $ | Start / end of input; line boundaries with m |
| \b / \B | Word boundary / non-boundary |
| a* | Repeat zero or more times |
| a+ | Repeat one or more times |
| a? | Optional, zero or one time |
| a{3} | Exactly three repetitions |
| a{2,5} | Between two and five repetitions |
| a{2,} | At least two repetitions |
| a+? | Lazy repetition, match as little as possible |
| a|b | Alternation |
| (abc) | Capturing group |
| (?:abc) | Non-capturing group |
| (?<name>abc) | Named capturing group |
| \1 / \k<name> | Numeric / named backreference |
| (?=abc) | Positive lookahead |
| (?!abc) | Negative lookahead |
| (?<=abc) | Positive lookbehind |
| (?<!abc) | Negative lookbehind |
| \n / \r / \t | Line feed / carriage return / tab |
| \x41 / \u0041 | Hexadecimal / Unicode escape |
| \u{1F600} | Unicode code point (u or v) |
| \p{Letter} / \P{Letter} | Unicode property / negated property (u or v) |
| [\p{ASCII}&&\p{Letter}] | Unicode set intersection (v) |
| [\p{Letter}--[a-z]] | Unicode set subtraction (v) |
| g | Global matching |
| i | Ignore case |
| m | Multiline anchors |
| s | Dot matches line terminators |
| u | Unicode mode |
| v | Unicode sets mode; mutually exclusive with u |
Examples
/^\d{3}$/ matches "123", not "1234".
/a+?/g matches each "a" separately in "aaa".Specification / reference