Toolbox / Regex syntax reference Runs in your browser中文
Development

Regex syntax reference

Look up JavaScript regex quantifiers, groups, assertions, and flags.

Ctrl / ⌘ + Enter Run

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

Less switching. More focus.Functional build · Validation in progress

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

Regular expression lab

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.

SyntaxMeaning
abcLiteral text
.Any character (except line terminators by default)
\d / \DDigit / non-digit
\w / \WWord character / non-word character
\s / \SWhitespace / non-whitespace
[abc]Character set
[^abc]Negated character set
[a-z]Character range
^ / $Start / end of input; line boundaries with m
\b / \BWord 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|bAlternation
(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 / \tLine feed / carriage return / tab
\x41 / \u0041Hexadecimal / 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)
gGlobal matching
iIgnore case
mMultiline anchors
sDot matches line terminators
uUnicode mode
vUnicode sets mode; mutually exclusive with u

Examples

/^\d{3}$/ matches "123", not "1234".
/a+?/g matches each "a" separately in "aaa".
Specification / reference