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 classesFull pattern
/a.c/gSample text
abc a-c axcMatches
abca-caxc3 matches\dA digit 0-9, same as [0-9]Character classesFull pattern
/\d+/gSample text
Order 42 has 7 itemsMatches
4272 matches\DAny character that is not a digitCharacter classesFull pattern
/\D+/gSample text
123abc456Matches
abc1 matches\wWord character: letter, digit or underscoreCharacter classesFull pattern
/\w+/gSample text
user_name-42Matches
user_name422 matches\WAny character that is not a word characterCharacter classesFull pattern
/\W+/gSample text
hello, world!Matches
,!2 matches\sWhitespace: space, tab, line breakCharacter classesFull pattern
/\s+/gSample text
a b cMatches
2 matches\SAny non-whitespace characterCharacter classesFull pattern
/\S+/gSample text
a b cMatches
abc3 matches[abc]Any single character from the setCharacter classesFull pattern
/[abc]+/gSample text
cab dabMatches
cabab2 matches[^abc]Any character not in the setCharacter classesFull pattern
/[^abc]+/gSample text
abcxyz123Matches
xyz1231 matches[a-z]A character rangeCharacter classesFull pattern
/[a-z]+/gSample text
ABC def GHIMatches
def1 matches[a-zA-Z0-9_]Several ranges combinedCharacter classesFull pattern
/[a-zA-Z0-9_]+/gSample text
id_42 Name!Matches
id_42Name2 matches[^0-9]Everything except digitsCharacter classesFull pattern
/[^0-9]+/gSample text
a1b2c3Matches
abc3 matches[\d]Character classes are allowed inside a setCharacter classesFull pattern
/[\d]+/gSample text
abc123defMatches
1231 matches[a\-z]An escaped hyphen means a literal hyphenCharacter classesFull pattern
/[a\-z]+/gSample text
a-z bMatches
a-z1 matches[\u4e00-\u9fff]The common CJK ideograph rangeCharacter classesFull pattern
/[\u4e00-\u9fff]+/gSample text
中文 mingled 混排Matches
中文混排2 matches[\s\S]Any character including line breaks (unlike .)Character classesFull pattern
/[\s\S]+/gSample text
line1 line2Matches
line1 line21 matches[aeiou]A set of vowelsCharacter classesFull pattern
/[aeiou]+/gSample text
banana bananaMatches
aaaaaa6 matches[\w-]Word characters or hyphensCharacter classesFull pattern
/[\w-]+/gSample text
kebab-case nameMatches
kebab-casename2 matches*Zero or more of the preceding elementQuantifiersFull pattern
/ab*c/gSample text
ac abc abbbcMatches
acabcabbbc3 matches+One or more of the preceding elementQuantifiersFull pattern
/ab+c/gSample text
ac abc abbbcMatches
abcabbbc2 matches?Zero or one of the preceding elementQuantifiersFull pattern
/colou?r/gSample text
color colourMatches
colorcolour2 matches{n}Exactly n repetitionsQuantifiersFull pattern
/\d{3}/gSample text
12 345 6789Matches
3456782 matches{n,}At least n repetitionsQuantifiersFull pattern
/\d{2,}/gSample text
1 23 456Matches
234562 matches{n,m}Between n and m repetitionsQuantifiersFull pattern
/\d{2,4}/gSample text
1234567Matches
12345672 matches*?Lazy quantifier: as few repetitions as possibleQuantifiersFull pattern
/<.*?>/gSample text
<a><b>Matches
<a><b>2 matches+?Lazy quantifier with at least one repetitionQuantifiersFull pattern
/".+?"/gSample text
"a" "b"Matches
"a""b"2 matches??Lazy optional: prefer zero repetitionsQuantifiersFull pattern
/https??/gSample text
http httpsMatches
httphttp2 matches{n,m}?Lazy version of a range quantifierQuantifiersFull pattern
/a{1,3}?/gSample text
aaaMatches
aaa3 matches.*Greedy: match as far as possibleQuantifiersFull pattern
/a.*c/gSample text
abc abcMatches
abc abc1 matches.*?Lazy: match as little as possibleQuantifiersFull pattern
/a.*?c/gSample text
abc abcMatches
abcabc2 matchesx{0,1}{0,1} is equivalent to ?QuantifiersFull pattern
/x{0,1}y/gSample text
xy yMatches
xyy2 matches(ab)+The quantifier applies to the whole groupQuantifiersFull pattern
/(ab)+/gSample text
abababMatches
ababab1 matches(abc)Capturing group, referenced later as $1, $2Groups & referencesFull pattern
/(\w+)@(\w+)/gSample text
alice@example bob@testMatches
alice@examplebob@test2 matches(?:abc)Groups without capturing (no numbering)Groups & referencesFull pattern
/(?:ab)+c/gSample text
ababcMatches
ababc1 matches(?<name>...)Named capture group for readabilityGroups & referencesFull pattern
/(?<year>\d{4})-(?<month>\d{2})/gSample text
2026-10Matches
2026-101 matches\k<name>Back-reference to a named groupGroups & referencesFull pattern
/(?<q>")\w+\k<q>/gSample text
"hi" "yo"Matches
"hi""yo"2 matches\1Back-reference to group 1 (repeated letters)Groups & referencesFull pattern
/(\w)\1/gSample text
hello bookMatches
lloo2 matchesa|bAlternation: match either sideGroups & referencesFull pattern
/cat|dog/gSample text
cat dog birdMatches
catdog2 matches(?:a|b)+Repeated alternation inside a groupGroups & referencesFull pattern
/(?:cat|dog)+/gSample text
catdogcatMatches
catdogcat1 matches((a)(b))Nested groups, numbered by opening parenthesisGroups & referencesFull pattern
/((a)(b))/gSample text
abMatches
ab1 matches$1Replacement reference to group 1 ("$2 $1" swaps)Groups & referencesFull pattern
/(\w+) (\w+)/gSample text
hello worldMatches
hello world1 matches$&In replacements, $& is the whole matchGroups & referencesFull pattern
/\d+/gSample text
abc 123 defMatches
1231 matches$<name>Replacement reference to a named groupGroups & referencesFull pattern
/(?<word>\w+)/gSample text
helloMatches
hello1 matches$$Outputs a literal dollar sign in replacementsGroups & referencesFull pattern
/a/gSample text
aMatches
a1 matches()An empty group, useful as a placeholderGroups & referencesFull pattern
/()b/gSample text
abMatches
b1 matches^Start of input (line start with the m flag)AssertionsFull pattern
/^\w+/gmSample text
hello worldMatches
hello1 matches$End of inputAssertionsFull pattern
/\w+$/gSample text
hello worldMatches
world1 matches\bWord boundary, avoids matching dog inside hotdogAssertionsFull pattern
/\bdog\b/gSample text
dog hotdog dogMatches
dogdog2 matches\BNon-word boundaryAssertionsFull pattern
/\Bdog\B/gSample text
hotdogish dogMatches
dog1 matches(?=x)Positive lookahead: the next characters must matchAssertionsFull pattern
/\d+(?=元)/gSample text
价格 100元 与 50 件Matches
1001 matches(?!x)Negative lookahead: the next characters must not matchAssertionsFull pattern
/\d+(?!元)/gSample text
100元 50 件Matches
10502 matches(?<=x)Positive lookbehind: the previous characters must matchAssertionsFull pattern
/(?<=\$)\d+/gSample text
price $42 and 30Matches
421 matches(?<!x)Negative lookbehind: the previous characters must not matchAssertionsFull pattern
/(?<!\$)\b\d+\b/gSample text
$42 and 30Matches
301 matches^ + mWith the m flag ^ matches the start of every lineAssertionsFull pattern
/^\w+/gmSample text
one two threeMatches
onetwothree3 matches$ + mWith the m flag $ matches the end of every lineAssertionsFull pattern
/\w+$/gmSample text
one twoMatches
onetwo2 matches(?=.*\d)(?=.*[a-z])Combining lookaheads to express password rulesAssertionsFull pattern
/^(?=.*\d)(?=.*[a-z]).{6,}$/gSample text
abc123Matches
abc1231 matches(?!.*(.)\1)Rejecting repeated adjacent charactersAssertionsFull pattern
/^(?!.*(.)\1).+$/gSample text
abcdefMatches
abcdef1 matches(?<=\s)x(?=\s)Both assertions to target a word surrounded by spacesAssertionsFull pattern
/(?<=\s)cat(?=\s)/gSample text
a cat bMatches
cat1 matches^(?!_)Asserting the input does not start with an underscoreAssertionsFull pattern
/^(?!_)\w+$/gSample text
nameMatches
name1 matches(?<=\.)\w+$Extracting an extension without the dotAssertionsFull pattern
/(?<=\.)\w+$/gSample text
report.pdfMatches
pdf1 matches(?=(\w+))Capturing inside a lookaheadAssertionsFull pattern
/(?=(\d{2}))/gSample text
ab12cd34Matches
2 matchesfoo(?!bar)Matches foo when not followed by barAssertionsFull pattern
/foo(?!bar)/gSample text
foo foobarMatches
foo1 matchesgGlobal: find every match, not just the firstFlagsFull pattern
/a/gSample text
bananaMatches
aaa3 matchesiCase-insensitive matchingFlagsFull pattern
/hello/giSample text
Hello HELLO helloMatches
HelloHELLOhello3 matchesm^ and $ match at line boundariesFlagsFull pattern
/^b/gmSample text
a b cMatches
b1 matchessLets . match line breaks tooFlagsFull pattern
/a.b/gsSample text
a bMatches
a b1 matchesuUnicode mode: code-point aware, enables \p{...}FlagsFull pattern
/^.$/guSample text
👍Matches
👍1 matchesySticky: matches only at lastIndexFlagsFull pattern
/foo/gySample text
foofooMatches
foofoo2 matchesdAdds match indices to the resultFlagsFull pattern
/\d+/gdSample text
abc 123Matches
1231 matches[\w.%+-]+@[\w.-]+\.[A-Za-z]{2,}Loose email: pick addresses out of proseCommon patternsFull pattern
/[\w.%+-]+@[\w.-]+\.[A-Za-z]{2,}/gSample text
contact hi@example.com nowMatches
hi@example.com1 matches^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$Strict email: validate the whole inputCommon patternsFull pattern
/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/gSample text
alice@example.comMatches
alice@example.com1 matches^https?:\/\/[\w.-]+(?::\d+)?(?:\/[^\s]*)?$http/https URL with optional port and pathCommon patternsFull pattern
/^https?:\/\/[\w.-]+(?::\d+)?(?:\/[^\s]*)?$/gSample text
https://example.com/docs?page=1Matches
https://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 patternsFull pattern
/^(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z]{2,}$/gSample text
www.example.comMatches
www.example.com1 matches\d{1,3}(?:\.\d{1,3}){3}Loose IPv4 matcherCommon patternsFull pattern
/\d{1,3}(?:\.\d{1,3}){3}/gSample text
ip 192.168.1.1 okMatches
192.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 patternsFull 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}/gSample text
192.168.1.1 与 999.1.1.1Matches
192.168.1.199.1.1.12 matches(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}Fully written IPv6 addressCommon patternsFull pattern
/(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}/gSample text
2001:0db8:0000:0000:0000:ff00:0042:8329Matches
2001:0db8:0000:0000:0000:ff00:0042:83291 matches^\d{4}-\d{2}-\d{2}$YYYY-MM-DD dateCommon patternsFull pattern
/^\d{4}-\d{2}-\d{2}$/gSample text
2026-10-10Matches
2026-10-101 matches^(\d{4})年(\d{1,2})月(\d{1,2})日$Chinese date with captured year, month, dayCommon patternsFull pattern
/^(\d{4})年(\d{1,2})月(\d{1,2})日$/gSample text
2026年10月10日Matches
2026年10月10日1 matches^([01]\d|2[0-3]):[0-5]\d$24-hour HH:MM timeCommon patternsFull pattern
/^([01]\d|2[0-3]):[0-5]\d$/gSample text
09:30Matches
09:301 matches^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$ISO 8601 timestampCommon patternsFull pattern
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/gSample text
2026-10-10T08:30:00ZMatches
2026-10-10T08:30:00Z1 matches^1[3-9]\d{9}$Mainland China mobile numberCommon patternsFull pattern
/^1[3-9]\d{9}$/gSample text
13800138000Matches
138001380001 matches^0\d{2,3}-\d{7,8}$Chinese landline with area codeCommon patternsFull pattern
/^0\d{2,3}-\d{7,8}$/gSample text
010-12345678Matches
010-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 patternsFull 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]$/gSample text
11010119900307721XMatches
11010119900307721X1 matches^[1-9]\d{5}$Chinese 6-digit postal codeCommon patternsFull pattern
/^[1-9]\d{5}$/gSample text
100000Matches
1000001 matches^[\u4e00-\u9fa5][A-Z][A-Z0-9]{5}$Chinese licence plate (standard cars)Common patternsFull pattern
/^[\u4e00-\u9fa5][A-Z][A-Z0-9]{5}$/gSample text
京A12345Matches
京A123451 matches^[\u4e00-\u9fa5]{2,4}$Chinese name of 2–4 charactersCommon patternsFull pattern
/^[\u4e00-\u9fa5]{2,4}$/gSample text
张三丰Matches
张三丰1 matches^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$Strong password: 8+ chars with upper, lower, digit and symbolCommon patternsFull pattern
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$/gSample text
Abc123!@#Matches
Abc123!@#1 matches^[a-zA-Z][a-zA-Z0-9_]{2,15}$Username: starts with a letter, 3–16 charsCommon patternsFull pattern
/^[a-zA-Z][a-zA-Z0-9_]{2,15}$/gSample text
alice_2026Matches
alice_20261 matches#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\bHex colour valueCommon patternsFull pattern
/#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b/gSample text
color: #fff and #A1B2C3Matches
#fff#A1B2C32 matchesrgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)rgb() / rgba() colourCommon patternsFull pattern
/rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)/gSample text
rgb(255, 0, 0) rgba(0, 0, 0, 0.5)Matches
rgb(255, 0, 0)rgba(0, 0, 0, 0.5)2 matches^-?\d+$Integer, optionally negativeCommon patternsFull pattern
/^-?\d+$/gSample text
-42Matches
-421 matches-?\d+\.\d+Decimal numberCommon patternsFull pattern
/-?\d+\.\d+/gSample text
3.14 -0.5Matches
3.14-0.52 matches[+-]?\d+(?:\.\d+)?[eE][+-]?\d+Scientific notationCommon patternsFull pattern
/[+-]?\d+(?:\.\d+)?[eE][+-]?\d+/gSample text
1.5e10 -3E-5Matches
1.5e10-3E-52 matches\b\d{1,3}(?:,\d{3})+\bNumber with thousands separatorsCommon patternsFull pattern
/\b\d{1,3}(?:,\d{3})+\b/gSample text
total 1,234,567 itemsMatches
1,234,5671 matches\d+\.\d{2}(?=\s|$)Money amount with two decimalsCommon patternsFull pattern
/\d+\.\d{2}(?=\s|$)/gSample text
price 19.90 nowMatches
19.901 matches\d+(?:\.\d+)?%PercentageCommon patternsFull pattern
/\d+(?:\.\d+)?%/gSample text
增长 12.5% 与 30%Matches
12.5%30%2 matches0[xX][0-9a-fA-F]+Hexadecimal literalCommon patternsFull pattern
/0[xX][0-9a-fA-F]+/gSample text
0xFF 0X1a 10Matches
0xFF0X1a2 matches0[bB][01]+Binary literalCommon patternsFull pattern
/0[bB][01]+/gSample text
0b1010 0B11 5Matches
0b10100B112 matches0[oO][0-7]+Octal literalCommon patternsFull pattern
/0[oO][0-7]+/gSample text
0o755 8Matches
0o7551 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 patternsFull pattern
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/gSample text
f47ac10b-58cc-4372-a567-0e02b2c3d479Matches
f47ac10b-58cc-4372-a567-0e02b2c3d4791 matches^[a-f0-9]{32}$MD5 hex digestCommon patternsFull pattern
/^[a-f0-9]{32}$/gSample text
d41d8cd98f00b204e9800998ecf8427eMatches
d41d8cd98f00b204e9800998ecf8427e1 matches^[a-f0-9]{64}$SHA-256 hex digestCommon patternsFull pattern
/^[a-f0-9]{64}$/gSample text
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015adMatches
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad1 matches^[A-Za-z0-9+/]+={0,2}$Base64 stringCommon patternsFull pattern
/^[A-Za-z0-9+/]+={0,2}$/gSample text
aGVsbG8=Matches
aGVsbG8=1 matches^[\w-]+\.[\w-]+\.[\w-]+$JWT: three dot-separated segmentsCommon patternsFull pattern
/^[\w-]+\.[\w-]+\.[\w-]+$/gSample text
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.abc123Matches
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.abc1231 matches^(?:4\d{12}(?:\d{3})?|5[1-5]\d{14})$Card number (simple Visa / MasterCard check)Common patternsFull pattern
/^(?:4\d{12}(?:\d{3})?|5[1-5]\d{14})$/gSample text
4111111111111111Matches
41111111111111111 matches<\/?[a-zA-Z][\w-]*(?:\s[^<>]*)?>HTML tag including attributesCommon patternsFull pattern
/<\/?[a-zA-Z][\w-]*(?:\s[^<>]*)?>/gSample text
<p class="x">text</p>Matches
<p class="x"></p>2 matches\[([^\]]+)\]\(([^)]+)\)Markdown link with captured text and URLCommon patternsFull pattern
/\[([^\]]+)\]\(([^)]+)\)/gSample text
see [文档](https://example.com)Matches
[文档](https://example.com)1 matches"[^"\\]*(?:\\.[^"\\]*)*"Double-quoted string with escaped quotesCommon patternsFull pattern
/"[^"\\]*(?:\\.[^"\\]*)*"/gSample text
"hello \"world\""Matches
"hello \"world\""1 matches^([^,\n]+)(?:,([^,\n]+))*$Simple CSV row (no quoted fields)Common patternsFull pattern
/^([^,\n]+)(?:,([^,\n]+))*$/gSample text
a,b,cMatches
a,b,c1 matches^(?:\/[\w.-]+)+\/?$Absolute Unix pathCommon patternsFull pattern
/^(?:\/[\w.-]+)+\/?$/gSample text
/usr/local/binMatches
/usr/local/bin1 matches^[A-Za-z]:\\(?:[^\\/:*?"<>|]+\\?)*$Absolute Windows pathCommon patternsFull pattern
/^[A-Za-z]:\\(?:[^\\/:*?"<>|]+\\?)*$/gSample text
C:\Users\aliceMatches
C:\Users\alice1 matches\.\w+$File extensionCommon patternsFull pattern
/\.\w+$/gSample text
report.pdfMatches
.pdf1 matches#[\w\u4e00-\u9fff]+Hashtag, Chinese and EnglishCommon patternsFull pattern
/#[\w\u4e00-\u9fff]+/gSample text
发帖 #unikit #工具 很好用Matches
#unikit#工具2 matches@[A-Za-z0-9_]{2,}@-mention handleCommon patternsFull pattern
/@[A-Za-z0-9_]{2,}/gSample text
@alice @bob_2Matches
@alice@bob_22 matches\p{Emoji_Presentation}+Emoji characters (requires the u flag)Common patternsFull pattern
/\p{Emoji_Presentation}+/guSample text
hello 👍🎉 worldMatches
👍🎉1 matches\.Escaped dot: matches a literal full stopEscapes & UnicodeFull pattern
/\d+\.\d+/gSample text
pi is 3.14Matches
3.141 matches\*Escaped star: matches a literal asteriskEscapes & UnicodeFull pattern
/a\*b/gSample text
a*bMatches
a*b1 matches\/Escaped slash, common in regex literalsEscapes & UnicodeFull pattern
/^\/\w+/gSample text
/homeMatches
/home1 matches\\Matches a single backslashEscapes & UnicodeFull pattern
/\\/gSample text
C:\UsersMatches
\1 matches\nLine feed characterEscapes & UnicodeFull pattern
/\n/gSample text
line1 line2Matches
1 matches\tTab characterEscapes & UnicodeFull pattern
/\t/gSample text
a bMatches
1 matches\rCarriage return (CRLF text)Escapes & UnicodeFull pattern
/\r/gSample text
a bMatches
1 matches\x41Two-digit hex escape: \x41 is AEscapes & UnicodeFull pattern
/\x41+/gSample text
AAAMatches
AAA1 matches\u4e2dFour-digit Unicode escapeEscapes & UnicodeFull pattern
/\u4e2d\u6587/gSample text
中文Matches
中文1 matches\u{1F600}Code point escape, requires the u flagEscapes & UnicodeFull pattern
/\u{1F600}/guSample text
😀Matches
😀1 matches\p{L}Unicode letter (requires the u flag)Escapes & UnicodeFull pattern
/\p{L}+/guSample text
中文 abc 123Matches
中文abc2 matches\p{Nd}Unicode decimal digit (needs the u flag)Escapes & UnicodeFull pattern
/\p{Nd}+/guSample text
abc 123 中文Matches
1231 matches\P{L}The complement of \p{L}Escapes & UnicodeFull pattern
/\P{L}+/guSample text
abc 123Matches
1231 matches\p{Script=Han}Filter by script; Han means CJK ideographsEscapes & UnicodeFull pattern
/\p{Script=Han}+/guSample 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断言常用正则