RegexLab
EN

Online Regex Tester, Visual Explainer & Cheat Sheet

Test text

  • Match
  • $1
  • $2
  • $3

Token explanation

    Replace preview

    Output

    
              

    Presets

    © 2026 RegexLab Runs in your browser. SurfsharkCorel Disclosure: sponsored links may earn us a commission, at no extra cost to you.

    Code snippets

    A ready-to-run snippet for the pattern, flags, text, and replacement above.

    Regex quick reference

    Character classes, anchors, quantifiers, groups, lookarounds, and flags. This section stays readable with JavaScript turned off.

    Character classes

    TokenMeaning
    .Any character except a line break
    \dA digit 0–9
    \DAnything that is not a digit
    \wA letter, digit, or underscore
    \WNot a letter, digit, or underscore
    \sWhitespace: space, tab, or line break
    \SAnything that is not whitespace
    [abc]One of a, b, or c
    [a-z]One character in the range
    [^0-9]One character outside the set

    Anchors

    TokenMeaning
    ^Start of the text, or of a line when m is on
    $End of the text, or of a line when m is on
    \bBoundary between a word character and a non-word character
    \BA position that is not a word boundary

    Quantifiers

    TokenMeaning
    *Zero or more
    +One or more
    ?Zero or one
    {n}Exactly n
    {m,n}Between m and n
    {m,}m or more
    *?Zero or more, preferring the shortest match
    +?One or more, preferring the shortest match

    Groups & lookarounds

    TokenMeaning
    (abc)Capturing group, referenced as $1
    (?:abc)Group without a capture
    (?<name>abc)Named group, referenced as $<name>
    \1The text captured by group 1
    \k<name>The text captured by a named group
    (?=abc)Positive lookahead
    (?!abc)Negative lookahead
    (?<=abc)Positive lookbehind
    (?<!abc)Negative lookbehind
    a|ba or b

    Flags

    FlagMeaning
    gFind every match, not just the first
    iIgnore letter case
    mLet ^ and $ match at each line
    sLet . match a line break
    uUnicode mode for code points and escapes

    Questions

    Does RegexLab send my pattern or test text to a server?

    No. Matching, highlighting, the token explanation, and the replacement preview all run in your browser.

    What do the flags g, i, m, s, and u change?

    g finds every match, i ignores case, m lets ^ and $ work on each line, s lets the dot match line breaks, and u turns on Unicode mode.

    How do capture groups show up?

    Each full match is highlighted, and $1, $2, $3, and named groups get their own colors plus a row in the match list. The replacement box accepts $1, $2, $&, and $<name>.

    Can I copy the pattern into Python, Go, or Rust?

    Yes. The snippet panel writes JavaScript, Python (re), Go (regexp), and Rust (regex) from the pattern, flags, and replacement you have open.