Regular Expression Tester
Test and validate regular expressions with visual results
Regular Expression
Example: \b\w+\b to match whole words
Test String
Replacement Pattern (for RegEx replace)
Use $1, $2, etc. to refer to capture groups
Regular Expression Quick Reference
Character Classes
| Symbol | Description | Example |
|---|---|---|
| . | Matches any character except newline | a.c matches "abc", "a2c", etc. |
| \d | Matches any digit (0-9) | \d{3} matches "123", "456", etc. |
| \D | Matches any non-digit | \D+ matches "abc", "!@#", etc. |
| \w | Matches any word character (a-z, A-Z, 0-9, _) | \w+ matches "abc123", "test_123", etc. |
| \W | Matches any non-word character | \W+ matches "!@#", " ", etc. |
| \s | Matches any whitespace character | a\sb matches "a b", "a\tb", etc. |
| \S | Matches any non-whitespace character | \S+ matches "abc", "123", etc. |
| [abc] | Matches any of the characters in the brackets | [aeiou] matches any vowel |
| [^abc] | Matches any character not in the brackets | [^0-9] matches any non-digit |
Quantifiers
| Symbol | Description | Example |
|---|---|---|
| * | Matches 0 or more occurrences | a* matches "", "a", "aa", etc. |
| + | Matches 1 or more occurrences | a+ matches "a", "aa", etc., but not "" |
| ? | Matches 0 or 1 occurrence | colou?r matches "color" and "colour" |
| {n} | Matches exactly n occurrences | \d{3} matches "123", "456", etc. |
| {n,} | Matches n or more occurrences | \d{2,} matches "12", "123", etc. |
| {n,m} | Matches between n and m occurrences | \d{2,4} matches "12", "123", "1234" |
Anchors and Boundaries
| Symbol | Description | Example |
|---|---|---|
| ^ | Matches the beginning of a string | ^abc matches "abc" in "abc123", but not in "123abc" |
| $ | Matches the end of a string | abc$ matches "abc" in "123abc", but not in "abc123" |
| \b | Word boundary | \bcat\b matches "cat" in "the cat sat", but not in "category" |
| \B | Non-word boundary | \Bcat\B matches "cat" in "verification", but not in "the cat" |
