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
| Symbol | Meaning | Example |
|---|---|---|
\d | A single digit (0-9) | \d+ → 123 |
\w | Word character (alphanumeric + underscore) | \w+ → user_id |
\s | Whitespace (space, tab, newline) | \s+ → 区切り |
. | Any character except newline | a.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)
| Symbol | Meaning | Example |
|---|---|---|
* | Zero or more of the previous | a* → "", a, aa |
+ | One or more of the previous | a+ → a, aa, aaa |
? | Zero or one of the previous | colou?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)
| Symbol | Meaning | Example |
|---|---|---|
^ | Start of string or line | ^abc → 先頭の abc |
$ | End of string or line | abc$ → 末尾の abc |
\b | Word boundary | \bcat\b → 単語の cat |
Groups, alternation, escape
| Symbol | Meaning | Example |
|---|---|---|
(...) | 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.