Skip to content
UniKit

Regex cheat sheet

A searchable cheat sheet of 129 regular-expression constructs grouped by character classes, quantifiers, groups, assertions, flags and common patterns — each with a runnable example and live matches.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

129 / 129 entries

  • .Any single character, line breaks excluded by defaultCharacter classes

    Full pattern/a.c/g

    Sample textabc a-c axc

    Matchesabca-caxc3 matches

  • \dA digit 0-9, same as [0-9]Character classes

    Full pattern/\d+/g

    Sample textOrder 42 has 7 items

    Matches4272 matches

  • \DAny character that is not a digitCharacter classes

    Full pattern/\D+/g

    Sample text123abc456

    Matchesabc1 matches

  • \wWord character: letter, digit or underscoreCharacter classes

    Full pattern/\w+/g

    Sample textuser_name-42

    Matchesuser_name422 matches

  • \WAny character that is not a word characterCharacter classes

    Full pattern/\W+/g

    Sample texthello, world!

    Matches, !2 matches

  • \sWhitespace: space, tab, line breakCharacter classes

    Full pattern/\s+/g

    Sample texta b c

    Matches 2 matches

  • \SAny non-whitespace characterCharacter classes

    Full pattern/\S+/g

    Sample texta b c

    Matchesabc3 matches

  • [abc]Any single character from the setCharacter classes

    Full pattern/[abc]+/g

    Sample textcab dab

    Matchescabab2 matches

  • [^abc]Any character not in the setCharacter classes

    Full pattern/[^abc]+/g

    Sample textabcxyz123

    Matchesxyz1231 matches

  • [a-z]A character rangeCharacter classes

    Full pattern/[a-z]+/g

    Sample textABC def GHI

    Matchesdef1 matches

  • [a-zA-Z0-9_]Several ranges combinedCharacter classes

    Full pattern/[a-zA-Z0-9_]+/g

    Sample textid_42 Name!

    Matchesid_42Name2 matches

  • [^0-9]Everything except digitsCharacter classes

    Full pattern/[^0-9]+/g

    Sample texta1b2c3

    Matchesabc3 matches

  • [\d]Character classes are allowed inside a setCharacter classes

    Full pattern/[\d]+/g

    Sample textabc123def

    Matches1231 matches

  • [a\-z]An escaped hyphen means a literal hyphenCharacter classes

    Full pattern/[a\-z]+/g

    Sample texta-z b

    Matchesa-z1 matches

  • [\u4e00-\u9fff]The common CJK ideograph rangeCharacter classes

    Full pattern/[\u4e00-\u9fff]+/g

    Sample text中文 mingled 混排

    Matches中文混排2 matches

  • [\s\S]Any character including line breaks (unlike .)Character classes

    Full pattern/[\s\S]+/g

    Sample textline1 line2

    Matchesline1 line21 matches

  • [aeiou]A set of vowelsCharacter classes

    Full pattern/[aeiou]+/g

    Sample textbanana banana

    Matchesaaaaaa6 matches

  • [\w-]Word characters or hyphensCharacter classes

    Full pattern/[\w-]+/g

    Sample textkebab-case name

    Matcheskebab-casename2 matches

  • *Zero or more of the preceding elementQuantifiers

    Full pattern/ab*c/g

    Sample textac abc abbbc

    Matchesacabcabbbc3 matches

  • +One or more of the preceding elementQuantifiers

    Full pattern/ab+c/g

    Sample textac abc abbbc

    Matchesabcabbbc2 matches

  • ?Zero or one of the preceding elementQuantifiers

    Full pattern/colou?r/g

    Sample textcolor colour

    Matchescolorcolour2 matches

  • {n}Exactly n repetitionsQuantifiers

    Full pattern/\d{3}/g

    Sample text12 345 6789

    Matches3456782 matches

  • {n,}At least n repetitionsQuantifiers

    Full pattern/\d{2,}/g

    Sample text1 23 456

    Matches234562 matches

  • {n,m}Between n and m repetitionsQuantifiers

    Full pattern/\d{2,4}/g

    Sample text1234567

    Matches12345672 matches

  • *?Lazy quantifier: as few repetitions as possibleQuantifiers

    Full pattern/<.*?>/g

    Sample text<a><b>

    Matches<a><b>2 matches

  • +?Lazy quantifier with at least one repetitionQuantifiers

    Full pattern/".+?"/g

    Sample text"a" "b"

    Matches"a""b"2 matches

  • ??Lazy optional: prefer zero repetitionsQuantifiers

    Full pattern/https??/g

    Sample texthttp https

    Matcheshttphttp2 matches

  • {n,m}?Lazy version of a range quantifierQuantifiers

    Full pattern/a{1,3}?/g

    Sample textaaa

    Matchesaaa3 matches

  • .*Greedy: match as far as possibleQuantifiers

    Full pattern/a.*c/g

    Sample textabc abc

    Matchesabc abc1 matches

  • .*?Lazy: match as little as possibleQuantifiers

    Full pattern/a.*?c/g

    Sample textabc abc

    Matchesabcabc2 matches

  • x{0,1}{0,1} is equivalent to ?Quantifiers

    Full pattern/x{0,1}y/g

    Sample textxy y

    Matchesxyy2 matches

  • (ab)+The quantifier applies to the whole groupQuantifiers

    Full pattern/(ab)+/g

    Sample textababab

    Matchesababab1 matches

  • (abc)Capturing group, referenced later as $1, $2Groups & references

    Full pattern/(\w+)@(\w+)/g

    Sample textalice@example bob@test

    Matchesalice@examplebob@test2 matches

  • (?:abc)Groups without capturing (no numbering)Groups & references

    Full pattern/(?:ab)+c/g

    Sample textababc

    Matchesababc1 matches

  • (?<name>...)Named capture group for readabilityGroups & references

    Full pattern/(?<year>\d{4})-(?<month>\d{2})/g

    Sample text2026-10

    Matches2026-101 matches

  • \k<name>Back-reference to a named groupGroups & references

    Full pattern/(?<q>")\w+\k<q>/g

    Sample text"hi" "yo"

    Matches"hi""yo"2 matches

  • \1Back-reference to group 1 (repeated letters)Groups & references

    Full pattern/(\w)\1/g

    Sample texthello book

    Matcheslloo2 matches

  • a|bAlternation: match either sideGroups & references

    Full pattern/cat|dog/g

    Sample textcat dog bird

    Matchescatdog2 matches

  • (?:a|b)+Repeated alternation inside a groupGroups & references

    Full pattern/(?:cat|dog)+/g

    Sample textcatdogcat

    Matchescatdogcat1 matches

  • ((a)(b))Nested groups, numbered by opening parenthesisGroups & references

    Full pattern/((a)(b))/g

    Sample textab

    Matchesab1 matches

  • $1Replacement reference to group 1 ("$2 $1" swaps)Groups & references

    Full pattern/(\w+) (\w+)/g

    Sample texthello world

    Matcheshello world1 matches

  • $&In replacements, $& is the whole matchGroups & references

    Full pattern/\d+/g

    Sample textabc 123 def

    Matches1231 matches

  • $<name>Replacement reference to a named groupGroups & references

    Full pattern/(?<word>\w+)/g

    Sample texthello

    Matcheshello1 matches

  • $$Outputs a literal dollar sign in replacementsGroups & references

    Full pattern/a/g

    Sample texta

    Matchesa1 matches

  • ()An empty group, useful as a placeholderGroups & references

    Full pattern/()b/g

    Sample textab

    Matchesb1 matches

  • ^Start of input (line start with the m flag)Assertions

    Full pattern/^\w+/gm

    Sample texthello world

    Matcheshello1 matches

  • $End of inputAssertions

    Full pattern/\w+$/g

    Sample texthello world

    Matchesworld1 matches

  • \bWord boundary, avoids matching dog inside hotdogAssertions

    Full pattern/\bdog\b/g

    Sample textdog hotdog dog

    Matchesdogdog2 matches

  • \BNon-word boundaryAssertions

    Full pattern/\Bdog\B/g

    Sample texthotdogish dog

    Matchesdog1 matches

  • (?=x)Positive lookahead: the next characters must matchAssertions

    Full pattern/\d+(?=元)/g

    Sample text价格 100元 与 50 件

    Matches1001 matches

  • (?!x)Negative lookahead: the next characters must not matchAssertions

    Full pattern/\d+(?!元)/g

    Sample text100元 50 件

    Matches10502 matches

  • (?<=x)Positive lookbehind: the previous characters must matchAssertions

    Full pattern/(?<=\$)\d+/g

    Sample textprice $42 and 30

    Matches421 matches

  • (?<!x)Negative lookbehind: the previous characters must not matchAssertions

    Full pattern/(?<!\$)\b\d+\b/g

    Sample text$42 and 30

    Matches301 matches

  • ^ + mWith the m flag ^ matches the start of every lineAssertions

    Full pattern/^\w+/gm

    Sample textone two three

    Matchesonetwothree3 matches

  • $ + mWith the m flag $ matches the end of every lineAssertions

    Full pattern/\w+$/gm

    Sample textone two

    Matchesonetwo2 matches

  • (?=.*\d)(?=.*[a-z])Combining lookaheads to express password rulesAssertions

    Full pattern/^(?=.*\d)(?=.*[a-z]).{6,}$/g

    Sample textabc123

    Matchesabc1231 matches

  • (?!.*(.)\1)Rejecting repeated adjacent charactersAssertions

    Full pattern/^(?!.*(.)\1).+$/g

    Sample textabcdef

    Matchesabcdef1 matches

  • (?<=\s)x(?=\s)Both assertions to target a word surrounded by spacesAssertions

    Full pattern/(?<=\s)cat(?=\s)/g

    Sample texta cat b

    Matchescat1 matches

  • ^(?!_)Asserting the input does not start with an underscoreAssertions

    Full pattern/^(?!_)\w+$/g

    Sample textname

    Matchesname1 matches

  • (?<=\.)\w+$Extracting an extension without the dotAssertions

    Full pattern/(?<=\.)\w+$/g

    Sample textreport.pdf

    Matchespdf1 matches

  • (?=(\w+))Capturing inside a lookaheadAssertions

    Full pattern/(?=(\d{2}))/g

    Sample textab12cd34

    Matches2 matches

  • foo(?!bar)Matches foo when not followed by barAssertions

    Full pattern/foo(?!bar)/g

    Sample textfoo foobar

    Matchesfoo1 matches

  • gGlobal: find every match, not just the firstFlags

    Full pattern/a/g

    Sample textbanana

    Matchesaaa3 matches

  • iCase-insensitive matchingFlags

    Full pattern/hello/gi

    Sample textHello HELLO hello

    MatchesHelloHELLOhello3 matches

  • m^ and $ match at line boundariesFlags

    Full pattern/^b/gm

    Sample texta b c

    Matchesb1 matches

  • sLets . match line breaks tooFlags

    Full pattern/a.b/gs

    Sample texta b

    Matchesa b1 matches

  • uUnicode mode: code-point aware, enables \p{...}Flags

    Full pattern/^.$/gu

    Sample text👍

    Matches👍1 matches

  • ySticky: matches only at lastIndexFlags

    Full pattern/foo/gy

    Sample textfoofoo

    Matchesfoofoo2 matches

  • dAdds match indices to the resultFlags

    Full pattern/\d+/gd

    Sample textabc 123

    Matches1231 matches

  • [\w.%+-]+@[\w.-]+\.[A-Za-z]{2,}Loose email: pick addresses out of proseCommon patterns

    Full pattern/[\w.%+-]+@[\w.-]+\.[A-Za-z]{2,}/g

    Sample textcontact hi@example.com now

    Matcheshi@example.com1 matches

  • ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$Strict email: validate the whole inputCommon patterns

    Full pattern/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/g

    Sample textalice@example.com

    Matchesalice@example.com1 matches

  • ^https?:\/\/[\w.-]+(?::\d+)?(?:\/[^\s]*)?$http/https URL with optional port and pathCommon patterns

    Full pattern/^https?:\/\/[\w.-]+(?::\d+)?(?:\/[^\s]*)?$/g

    Sample texthttps://example.com/docs?page=1

    Matcheshttps://example.com/docs?page=11 matches

  • ^(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z]{2,}$Domain name including subdomainsCommon patterns

    Full pattern/^(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z]{2,}$/g

    Sample textwww.example.com

    Matcheswww.example.com1 matches

  • \d{1,3}(?:\.\d{1,3}){3}Loose IPv4 matcherCommon patterns

    Full pattern/\d{1,3}(?:\.\d{1,3}){3}/g

    Sample textip 192.168.1.1 ok

    Matches192.168.1.11 matches

  • (?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}Strict IPv4: every octet within 0-255Common patterns

    Full pattern/(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}/g

    Sample text192.168.1.1 与 999.1.1.1

    Matches192.168.1.199.1.1.12 matches

  • (?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}Fully written IPv6 addressCommon patterns

    Full pattern/(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}/g

    Sample text2001:0db8:0000:0000:0000:ff00:0042:8329

    Matches2001:0db8:0000:0000:0000:ff00:0042:83291 matches

  • ^\d{4}-\d{2}-\d{2}$YYYY-MM-DD dateCommon patterns

    Full pattern/^\d{4}-\d{2}-\d{2}$/g

    Sample text2026-10-10

    Matches2026-10-101 matches

  • ^(\d{4})年(\d{1,2})月(\d{1,2})日$Chinese date with captured year, month, dayCommon patterns

    Full pattern/^(\d{4})年(\d{1,2})月(\d{1,2})日$/g

    Sample text2026年10月10日

    Matches2026年10月10日1 matches

  • ^([01]\d|2[0-3]):[0-5]\d$24-hour HH:MM timeCommon patterns

    Full pattern/^([01]\d|2[0-3]):[0-5]\d$/g

    Sample text09:30

    Matches09:301 matches

  • ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$ISO 8601 timestampCommon patterns

    Full pattern/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/g

    Sample text2026-10-10T08:30:00Z

    Matches2026-10-10T08:30:00Z1 matches

  • ^1[3-9]\d{9}$Mainland China mobile numberCommon patterns

    Full pattern/^1[3-9]\d{9}$/g

    Sample text13800138000

    Matches138001380001 matches

  • ^0\d{2,3}-\d{7,8}$Chinese landline with area codeCommon patterns

    Full pattern/^0\d{2,3}-\d{7,8}$/g

    Sample text010-12345678

    Matches010-123456781 matches

  • ^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}[\dXx]$Mainland China 18-digit ID numberCommon patterns

    Full pattern/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/g

    Sample text11010119900307721X

    Matches11010119900307721X1 matches

  • ^[1-9]\d{5}$Chinese 6-digit postal codeCommon patterns

    Full pattern/^[1-9]\d{5}$/g

    Sample text100000

    Matches1000001 matches

  • ^[\u4e00-\u9fa5][A-Z][A-Z0-9]{5}$Chinese licence plate (standard cars)Common patterns

    Full pattern/^[\u4e00-\u9fa5][A-Z][A-Z0-9]{5}$/g

    Sample text京A12345

    Matches京A123451 matches

  • ^[\u4e00-\u9fa5]{2,4}$Chinese name of 2–4 charactersCommon patterns

    Full pattern/^[\u4e00-\u9fa5]{2,4}$/g

    Sample text张三丰

    Matches张三丰1 matches

  • ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$Strong password: 8+ chars with upper, lower, digit and symbolCommon patterns

    Full pattern/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$/g

    Sample textAbc123!@#

    MatchesAbc123!@#1 matches

  • ^[a-zA-Z][a-zA-Z0-9_]{2,15}$Username: starts with a letter, 3–16 charsCommon patterns

    Full pattern/^[a-zA-Z][a-zA-Z0-9_]{2,15}$/g

    Sample textalice_2026

    Matchesalice_20261 matches

  • #(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\bHex colour valueCommon patterns

    Full pattern/#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b/g

    Sample textcolor: #fff and #A1B2C3

    Matches#fff#A1B2C32 matches

  • rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)rgb() / rgba() colourCommon patterns

    Full pattern/rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)/g

    Sample textrgb(255, 0, 0) rgba(0, 0, 0, 0.5)

    Matchesrgb(255, 0, 0)rgba(0, 0, 0, 0.5)2 matches

  • ^-?\d+$Integer, optionally negativeCommon patterns

    Full pattern/^-?\d+$/g

    Sample text-42

    Matches-421 matches

  • -?\d+\.\d+Decimal numberCommon patterns

    Full pattern/-?\d+\.\d+/g

    Sample text3.14 -0.5

    Matches3.14-0.52 matches

  • [+-]?\d+(?:\.\d+)?[eE][+-]?\d+Scientific notationCommon patterns

    Full pattern/[+-]?\d+(?:\.\d+)?[eE][+-]?\d+/g

    Sample text1.5e10 -3E-5

    Matches1.5e10-3E-52 matches

  • \b\d{1,3}(?:,\d{3})+\bNumber with thousands separatorsCommon patterns

    Full pattern/\b\d{1,3}(?:,\d{3})+\b/g

    Sample texttotal 1,234,567 items

    Matches1,234,5671 matches

  • \d+\.\d{2}(?=\s|$)Money amount with two decimalsCommon patterns

    Full pattern/\d+\.\d{2}(?=\s|$)/g

    Sample textprice 19.90 now

    Matches19.901 matches

  • \d+(?:\.\d+)?%PercentageCommon patterns

    Full pattern/\d+(?:\.\d+)?%/g

    Sample text增长 12.5% 与 30%

    Matches12.5%30%2 matches

  • 0[xX][0-9a-fA-F]+Hexadecimal literalCommon patterns

    Full pattern/0[xX][0-9a-fA-F]+/g

    Sample text0xFF 0X1a 10

    Matches0xFF0X1a2 matches

  • 0[bB][01]+Binary literalCommon patterns

    Full pattern/0[bB][01]+/g

    Sample text0b1010 0B11 5

    Matches0b10100B112 matches

  • 0[oO][0-7]+Octal literalCommon patterns

    Full pattern/0[oO][0-7]+/g

    Sample text0o755 8

    Matches0o7551 matches

  • ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$UUID v4Common patterns

    Full pattern/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/g

    Sample textf47ac10b-58cc-4372-a567-0e02b2c3d479

    Matchesf47ac10b-58cc-4372-a567-0e02b2c3d4791 matches

  • ^[a-f0-9]{32}$MD5 hex digestCommon patterns

    Full pattern/^[a-f0-9]{32}$/g

    Sample textd41d8cd98f00b204e9800998ecf8427e

    Matchesd41d8cd98f00b204e9800998ecf8427e1 matches

  • ^[a-f0-9]{64}$SHA-256 hex digestCommon patterns

    Full pattern/^[a-f0-9]{64}$/g

    Sample textba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad

    Matchesba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad1 matches

  • ^[A-Za-z0-9+/]+={0,2}$Base64 stringCommon patterns

    Full pattern/^[A-Za-z0-9+/]+={0,2}$/g

    Sample textaGVsbG8=

    MatchesaGVsbG8=1 matches

  • ^[\w-]+\.[\w-]+\.[\w-]+$JWT: three dot-separated segmentsCommon patterns

    Full pattern/^[\w-]+\.[\w-]+\.[\w-]+$/g

    Sample texteyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.abc123

    MatcheseyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.abc1231 matches

  • ^(?:4\d{12}(?:\d{3})?|5[1-5]\d{14})$Card number (simple Visa / MasterCard check)Common patterns

    Full pattern/^(?:4\d{12}(?:\d{3})?|5[1-5]\d{14})$/g

    Sample text4111111111111111

    Matches41111111111111111 matches

  • <\/?[a-zA-Z][\w-]*(?:\s[^<>]*)?>HTML tag including attributesCommon patterns

    Full pattern/<\/?[a-zA-Z][\w-]*(?:\s[^<>]*)?>/g

    Sample text<p class="x">text</p>

    Matches<p class="x"></p>2 matches

  • \[([^\]]+)\]\(([^)]+)\)Markdown link with captured text and URLCommon patterns

    Full pattern/\[([^\]]+)\]\(([^)]+)\)/g

    Sample textsee [文档](https://example.com)

    Matches[文档](https://example.com)1 matches

  • "[^"\\]*(?:\\.[^"\\]*)*"Double-quoted string with escaped quotesCommon patterns

    Full pattern/"[^"\\]*(?:\\.[^"\\]*)*"/g

    Sample text"hello \"world\""

    Matches"hello \"world\""1 matches

  • ^([^,\n]+)(?:,([^,\n]+))*$Simple CSV row (no quoted fields)Common patterns

    Full pattern/^([^,\n]+)(?:,([^,\n]+))*$/g

    Sample texta,b,c

    Matchesa,b,c1 matches

  • ^(?:\/[\w.-]+)+\/?$Absolute Unix pathCommon patterns

    Full pattern/^(?:\/[\w.-]+)+\/?$/g

    Sample text/usr/local/bin

    Matches/usr/local/bin1 matches

  • ^[A-Za-z]:\\(?:[^\\/:*?"<>|]+\\?)*$Absolute Windows pathCommon patterns

    Full pattern/^[A-Za-z]:\\(?:[^\\/:*?"<>|]+\\?)*$/g

    Sample textC:\Users\alice

    MatchesC:\Users\alice1 matches

  • \.\w+$File extensionCommon patterns

    Full pattern/\.\w+$/g

    Sample textreport.pdf

    Matches.pdf1 matches

  • #[\w\u4e00-\u9fff]+Hashtag, Chinese and EnglishCommon patterns

    Full pattern/#[\w\u4e00-\u9fff]+/g

    Sample text发帖 #unikit #工具 很好用

    Matches#unikit#工具2 matches

  • @[A-Za-z0-9_]{2,}@-mention handleCommon patterns

    Full pattern/@[A-Za-z0-9_]{2,}/g

    Sample text@alice @bob_2

    Matches@alice@bob_22 matches

  • \p{Emoji_Presentation}+Emoji characters (requires the u flag)Common patterns

    Full pattern/\p{Emoji_Presentation}+/gu

    Sample texthello 👍🎉 world

    Matches👍🎉1 matches

  • \.Escaped dot: matches a literal full stopEscapes & Unicode

    Full pattern/\d+\.\d+/g

    Sample textpi is 3.14

    Matches3.141 matches

  • \*Escaped star: matches a literal asteriskEscapes & Unicode

    Full pattern/a\*b/g

    Sample texta*b

    Matchesa*b1 matches

  • \/Escaped slash, common in regex literalsEscapes & Unicode

    Full pattern/^\/\w+/g

    Sample text/home

    Matches/home1 matches

  • \\Matches a single backslashEscapes & Unicode

    Full pattern/\\/g

    Sample textC:\Users

    Matches\1 matches

  • \nLine feed characterEscapes & Unicode

    Full pattern/\n/g

    Sample textline1 line2

    Matches 1 matches

  • \tTab characterEscapes & Unicode

    Full pattern/\t/g

    Sample texta b

    Matches 1 matches

  • \rCarriage return (CRLF text)Escapes & Unicode

    Full pattern/\r/g

    Sample texta b

    Matches 1 matches

  • \x41Two-digit hex escape: \x41 is AEscapes & Unicode

    Full pattern/\x41+/g

    Sample textAAA

    MatchesAAA1 matches

  • \u4e2dFour-digit Unicode escapeEscapes & Unicode

    Full pattern/\u4e2d\u6587/g

    Sample text中文

    Matches中文1 matches

  • \u{1F600}Code point escape, requires the u flagEscapes & Unicode

    Full pattern/\u{1F600}/gu

    Sample text😀

    Matches😀1 matches

  • \p{L}Unicode letter (requires the u flag)Escapes & Unicode

    Full pattern/\p{L}+/gu

    Sample text中文 abc 123

    Matches中文abc2 matches

  • \p{Nd}Unicode decimal digit (needs the u flag)Escapes & Unicode

    Full pattern/\p{Nd}+/gu

    Sample textabc 123 中文

    Matches1231 matches

  • \P{L}The complement of \p{L}Escapes & Unicode

    Full pattern/\P{L}+/gu

    Sample textabc 123

    Matches 1231 matches

  • \p{Script=Han}Filter by script; Han means CJK ideographsEscapes & Unicode

    Full pattern/\p{Script=Han}+/gu

    Sample text混合 han 汉字

    Matches混合汉字2 matches

What this tool does

  • Forgot how a construct is written? Browse by category — character classes, quantifiers, groups and references, assertions, flags, common patterns and escapes/Unicode.
  • Every entry ships with a runnable pattern and sample text, and matches are computed live, so you do not have to paste anything into a console first.
  • Debugging "why does my regex not match?" is easier next to the reference example: check whether you dropped a flag (g, say) or wrote the quantifier wrong.
  • Search by keyword to jump straight to an entry: "email" finds the common-pattern email regex and "lookahead" lists every lookahead form.

Example

Input

Search keyword "lookahead"

Output

4 entries: lookahead | (?=x) · negative-lookahead | (?!x) · password-lookaheads | (?=.*\d)(?=.*[a-z]) · lookahead-capture | (?=(\w+))

Search is case-insensitive and matches syntax, both descriptions, the example pattern and the id; the g flag is added automatically when an example runs.

Frequently asked questions

How many constructs are covered?

129 across seven categories: 18 character classes, 14 quantifiers, 13 groups and references, 17 assertions, 7 flags, 46 common patterns and 14 escapes/Unicode entries. The common patterns include copy-ready regexes for email, URLs and phone numbers.

Are the example matches computed live?

Yes. Each example runs through the page's JavaScript regex engine, so matches, capture groups and positions come from real execution rather than hard-coded text — which also makes engine differences visible.

Why do example patterns carry the g flag?

So every match in the sample text is listed. An entry's own flags are merged with g and deduplicated, so an entry that uses i runs as gi, keeping its meaning while showing all hits.

How many matches does a single example show?

At most 50. The cap keeps catastrophic backtracking or very long sample text from freezing the page; matching simply stops at the limit instead of looping forever.

Which regex engine do these examples target?

JavaScript RegExp, the ECMAScript dialect. Other languages differ noticeably — Python names groups with (?P<name>), and even \b behaves slightly differently in Java — so double-check when porting.

Keywords:regexregexp正则正则表达式cheat sheet速查lookahead断言常用正则

Related tools