Regex Tester
Test regular expressions in real time with match highlighting, capture groups, and position info.
Presets
Regular expression basics
A regular expression (regex) is a pattern that describes a set of strings. They're used everywhere in IT: log parsing, input validation, search-and-replace, firewall rules, and scripting.
Flags explained
g: Global- Find all matches in the string, not just the first one.
i: Case Insensitive- Match uppercase and lowercase letters interchangeably.
/abc/imatches "ABC", "abc", and "AbC". m: Multiline- Makes
^and$match the start and end of each line, not just the entire string.
Common patterns
| Pattern | Meaning |
|---|---|
. | Any character except newline |
\d | Any digit (0–9) |
\w | Word character (a–z, A–Z, 0–9, _) |
\s | Whitespace (space, tab, newline) |
^ | Start of string (or line with m flag) |
$ | End of string (or line with m flag) |
* | Zero or more of the preceding element |
+ | One or more of the preceding element |
? | Zero or one of the preceding element |
{n,m} | Between n and m of the preceding element |
[abc] | Any one of a, b, or c |
[^abc] | Any character except a, b, or c |
(group) | Capture group: extracts matched content |
a|b | Either a or b |
Capture groups
Parentheses () create capture groups that extract portions of a match.
For example, the pattern (\d4)-(\d2)-(\d2) against "2026-03-10"
produces three groups: "2026", "03", and "10". Groups are numbered left-to-right
starting at 1.
Practical examples for IT
- IPv4 addresses
\b\d{1,3}\.\d{"{1,3}"}.{"\"}d{"{1,3}"}.{"\"}d{"{1,3}"} matches IP-like patterns in log files. For strict validation (0-255 per octet), a more complex pattern is needed, but this works well for quick log searches. }
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} matches most email addresses. Full RFC 5322 compliance requires a much longer pattern, but this covers the vast majority of real-world addresses.\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2} matches ISO 8601 timestamps commonly found in application logs (e.g. 2026-03-22T14:30:00).([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2} matches both colon-separated (00:1A:2B:3C:4D:5E) and hyphen-separated formats.HTTP/\d\.\d" [45]\d{2} finds 4xx and 5xx errors in web server access logs. Change [45] to 5 to isolate server errors only.How to use this tool
Enter your regular expression in the pattern field and your test string in the text
area below. Matches are highlighted in real time as you type. Use the flag toggles
(g, i, m) to change matching behaviour. The
preset dropdown provides common patterns as a starting point.
The results panel shows each match with its position in the string and any captured groups. This is useful for verifying that your pattern extracts exactly the data you need before using it in scripts or log parsing pipelines.
Performance note
Some patterns with nested quantifiers like (a+)+ can cause catastrophic
backtracking, where the regex engine takes exponentially longer as the input grows.
This tester includes a 2-second timeout to prevent browser freezes. If you hit the
timeout, try simplifying nested repetition or using atomic groups.