Flags

Enter text and a regular expression, then press Run

Regex basics cheat sheet

A quick reference for the metacharacters, quantifiers, anchors, and groups you'll see most often. Pair it with the samples below.

Character classes

SymbolMeaningExample
\dA single digit (0-9)\d+ → 123
\wWord character (alphanumeric + underscore)\w+ → user_id
\sWhitespace (space, tab, newline)\s+ → 区切り
.Any character except newlinea.c → abc, axc
[abc]Any one of the characters in [ ][abc]+ → abca
[a-z]A character within the range[a-z]+ → hello
[^abc]Any character NOT in [^ ][^0-9] → 数字以外

Quantifiers (repetition)

SymbolMeaningExample
*Zero or more of the previousa* → "", a, aa
+One or more of the previousa+ → a, aa, aaa
?Zero or one of the previouscolou?r → color, colour
{n}Exactly n times\d{4} → 2024
{n,m}Between n and m times\d{2,4} → 12, 1234
*?Non-greedy (shortest match)<.*?> → 最短一致

Anchors (position)

SymbolMeaningExample
^Start of string or line^abc → 先頭の abc
$End of string or lineabc$ → 末尾の abc
\bWord boundary\bcat\b → 単語の cat

Groups, alternation, escape

SymbolMeaningExample
(...)Capturing group — pulls out the part in ( )(\d+)-(\d+)
(?:...)Non-capturing group (just for grouping)(?:abc)+ → 取り出さない
|OR (either side)cat|dog → cat または dog
\.Escape a metacharacter to its literal form\. → 文字としての .

Common regex patterns

Click any card to load its sample text and pattern, and see the result inline. Click the same card again to close it.

Numbers, dates, and times

Strings and identifiers

Contact info and URLs

Code and web

Advanced patterns