WebGroundwebground.app
Info & Guides · Developer Reference

Regular Expression (Regex) Cheat Sheet & Tester

Searchable reference for regex character classes, anchors, quantifiers, groups, lookarounds, and flags, with a live in-browser pattern tester.

Live regex tester

Matches: 2

Order #1042 shipped on 2026-11-14 and arrives 2026-11-18. Contact: [email protected]

Uses your browser's JavaScript (ECMAScript) regex engine.

Showing 38 of 38
  • .
    Meaning
    Any single character except a line break.
    Example
    a.cabc, a-c
  • \d
    Meaning
    Any digit from 0 to 9.
    Example
    \d\d42
  • \D
    Meaning
    Any character that is not a digit.
    Example
    \D+abc
  • \w
    Meaning
    A word character: ASCII letter, digit, or underscore.
    Example
    \w+user_42
  • \W
    Meaning
    Any character that is not a word character.
    Example
    \W@
  • \s
    Meaning
    Any whitespace: space, tab, or line break.
    Example
    a\sba b
  • \S
    Meaning
    Any character that is not whitespace.
    Example
    \S+hello
  • [abc]
    Meaning
    Any one of the characters inside the brackets.
    Example
    gr[ae]ygray, grey
  • [^abc]
    Meaning
    Any character except those inside the brackets.
    Example
    [^0-9]+abc
  • [a-z]
    Meaning
    Any character in the given range.
    Example
    [0-9A-F]+1F4
  • \p{L}
    Meaning
    Any Unicode letter in any script (needs the u flag).
    Example
    \p{L}+café
  • \.
    Meaning
    A backslash makes a special character literal, here a dot.
    Example
    \$\d+$5
  • ^
    Meaning
    Start of the string, or of each line with the m flag.
    Example
    ^HiHi there
  • $
    Meaning
    End of the string, or of each line with the m flag.
    Example
    end$the end
  • \b
    Meaning
    Position between a word character and a non-word character.
    Example
    \bcat\bcat
  • \B
    Meaning
    Position that is not a word boundary.
    Example
    \Bcatconcat
  • *
    Meaning
    Zero or more of the previous item.
    Example
    ab*cac, abbc
  • +
    Meaning
    One or more of the previous item.
    Example
    ab+cabc, abbc
  • ?
    Meaning
    Zero or one of the previous item (makes it optional).
    Example
    colou?rcolor, colour
  • {n}
    Meaning
    Exactly n of the previous item.
    Example
    \d{4}2026
  • {n,m}
    Meaning
    Between n and m of the previous item.
    Example
    \d{2,4}12, 1234
  • {n,}
    Meaning
    n or more of the previous item.
    Example
    a{2,}aa, aaaa
  • *? +?
    Meaning
    Lazy quantifier: matches as few characters as possible.
    Example
    <.+?><b>
  • (abc)
    Meaning
    Capturing group: groups tokens and remembers the match.
    Example
    (\d+)-(\d+)10-20
  • (?:abc)
    Meaning
    Groups tokens without remembering the match.
    Example
    (?:ab)+abab
  • (?<name>abc)
    Meaning
    Capturing group you can refer to by name.
    Example
    (?<year>\d{4})2026
  • \1
    Meaning
    Matches the same text that group 1 matched.
    Example
    (\w)\1ll
  • a|b
    Meaning
    Matches either the left or the right side.
    Example
    cat|dogcat, dog
  • (?=abc)
    Meaning
    Position followed by the pattern, without consuming it.
    Example
    \d+(?=%)50%
  • (?!abc)
    Meaning
    Position not followed by the pattern.
    Example
    \d+(?!px)12em
  • (?<=abc)
    Meaning
    Position preceded by the pattern, without consuming it.
    Example
    (?<=\$)\d+$99
  • (?<!abc)
    Meaning
    Position not preceded by the pattern.
    Example
    (?<!-)\d+7
  • g
    Meaning
    Global: find all matches instead of only the first.
    Example
    /a/ga, a, a
  • i
    Meaning
    Ignore case: uppercase and lowercase match each other.
    Example
    /hello/iHeLLo
  • m
    Meaning
    Multiline: ^ and $ match at the start and end of every line.
    Example
    /^\w+/mline starts
  • s
    Meaning
    Dot-all: the dot also matches line breaks.
    Example
    /a.b/sa\nb
  • u
    Meaning
    Unicode: enables \p{…} and full Unicode code points.
    Example
    /\p{Emoji}/u🎉
  • y
    Meaning
    Sticky: matches only at the current lastIndex position.
    Example
    /foo/ylastIndex

Reading a Regular Expression

A regular expression is a pattern made of literal characters and special tokens. Character classes describe which characters can match, quantifiers say how many times, anchors pin the match to a position, and groups capture parts of the match.

The tester above uses your browser's JavaScript regex engine, which follows the ECMAScript standard. Most tokens work the same way in Python, Java, PCRE, and .NET.

Common Pitfalls

Small details often cause patterns to match too much or nothing at all.

  • Escape special characters such as . * + ? ( ) [ ] { } | ^ $ \ when you mean them literally.
  • Quantifiers are greedy by default; add ? to make them lazy.
  • Without the g flag, only the first match is found.
  • Nested quantifiers like (a+)+ can be extremely slow on long input.

Frequently Asked Questions

Why does \w not match accented letters or Korean?+

In JavaScript, \w only covers ASCII letters, digits, and underscore. Use \p{L} with the u flag to match letters in any script.

Is my test text sent anywhere?+

No. Matching runs entirely in your browser.

Do lookbehinds work in every browser?+

All current versions of Chrome, Edge, Firefox, and Safari (16.4 and later) support lookbehind assertions.

Explore More on WebGround

View all