Regex Tester
Test JavaScript regular expressions with live match highlighting, a match list, and multiple test strings (one per line).
Ad unit (leaderboard)
Matches will appear here.
Regex symbols reference
Each symbol with a short description and example of what it matches.
▸Anchors & boundaries
| Symbol | Description | Example pattern | Matches (idea) |
|---|---|---|---|
| ^ | Start of string (start of each line with m flag). | ^Hello | "Hello" at start of text |
| $ | End of string (end of each line with m flag). | end$ | text ending in "end" |
| \b | Word boundary (between word \w and non-word). | \bcat\b | "cat" as whole word, not "category" |
| \B | Not a word boundary. | \Bcat | "cat" inside a word, e.g. "vacation" |
▸Character classes
| Symbol | Description | Example pattern | Matches (idea) |
|---|---|---|---|
| . | Any single character except newline (with s flag, includes newline). | a.c | "abc", "a1c" — not "a\nc" |
| \d | Digit 0–9. | \d{3} | "123" — three digits in a row |
| \D | Any non-digit. | \D+ | runs of letters/symbols between numbers |
| \w | Word character: letter, digit, or underscore. | \w+ | "foo", "x_1" |
| \W | Non-word character (spaces, punctuation). | \W | space, comma, @, etc. |
| \s | Whitespace (space, tab, newline, etc.). | \s+ | one or more spaces/tabs |
| \S | Non-whitespace. | \S+ | first "word" without spaces |
| [ ] | Any one character inside brackets. | [aeiou] | any single vowel |
| [^ ] | Any character NOT in brackets. | [^0-9] | any char that is not a digit |
| [a-z] | Range inside brackets. | [A-Z][a-z]+ | "Hello" style capital + lowercase |
▸Quantifiers (how many times)
| Symbol | Description | Example pattern | Matches (idea) |
|---|---|---|---|
| * | Zero or more of the previous. | ab*c | "ac", "abc", "abbbc" |
| + | One or more of the previous. | \d+ | "42", "007" — not "" |
| ? | Zero or one (optional). | colou?r | "color" or "colour" |
| {n} | Exactly n times. | \d{4} | exactly 4 digits, e.g. year |
| {n,} | At least n times. | \w{3,} | words with 3+ letters |
| {n,m} | Between n and m times. | \d{1,3} | 1 to 3 digits |
| *? +? ?? | Lazy (non-greedy): as few repeats as possible. | <.*?> | shortest span inside < > |
▸Groups & alternation
| Symbol | Description | Example pattern | Matches (idea) |
|---|---|---|---|
| ( ) | Capturing group; remembers match for \1, \2…. | (\w+)\s+\1 | repeated word: "hi hi" |
| (?: ) | Non-capturing group (grouping only). | (?:https?:)// | "http://" or "https://" |
| | | OR — match left or right side. | cat|dog | "cat" or "dog" |
| (?= ) | Positive lookahead: followed by pattern without consuming. | \d(?=px) | digit only if "px" follows |
| (?! ) | Negative lookahead: not followed by. | \d(?!px) | digit not before "px" |
| (?<= ) | Positive lookbehind (fixed length in some engines). | (?<=@)\w+ | word after @ |
| (?<! ) | Negative lookbehind. | (?<!\$)\d+ | digits not after $ |
▸Escaping & literals
| Symbol | Description | Example pattern | Matches (idea) |
|---|---|---|---|
| \ | Escape special characters to match them literally. | \. | a literal dot, not "any char" |
| \. | Literal period. | file\.txt | "file.txt" |
| \* \^ \$ etc. | Special chars need \ when you want the character itself. | \(\) | literal parentheses |
▸Common escapes
| Symbol | Description | Example pattern | Matches (idea) |
|---|---|---|---|
| \n | Newline character. | line\nline | two lines separated by newline |
| \t | Tab. | \t+ | one or more tabs |
| \\ | Backslash in pattern (in JS string often "\\"). | C:\\Users | Windows-style path segment |
▸Flags (checkboxes above)
| Symbol | Description | Example pattern | Matches (idea) |
|---|---|---|---|
| g | Global — find all matches, not just the first. | /\w+/g | every word in the string |
| i | Ignore case — A equals a. | /hello/i | "Hello", "HELLO" |
| m | Multiline — ^ and $ match each line. | ^# | start of every line |
| s | DotAll — . matches newline too. | .* | entire block including line breaks |
| u | Unicode mode — correct handling of surrogate pairs, \u{…}. | with u flag | full Unicode code points, not half-pairs |
Ad unit (rectangle)
How to use
- Enter your pattern (JavaScript regex syntax).
- Toggle flags: g for all matches, i for case-insensitive, m for multiline ^/$, s for dotAll, u for Unicode.
- Paste text in Test string to see highlighted matches and a match table.
- Use Multiple test strings to validate one pattern against many lines.
- Share URL copies a link with your pattern and sample text encoded.
- Expand Regex symbols reference below the tool for each symbol, description, and example.