Regex Tester
Test a regular expression on your own text, see what each part does, and get the matching grep and sed commands.
● Runs 100% in your browser — nothing you type leaves this page.
Examples
🔒 Tested in your browser and never sent anywhere. The page address keeps the pattern, not this text.
Result
203.0.113.7 - - [06/Nov/2026:09:12:45 +0000] "GET /api/users/42 HTTP/1.1" 200 512 198.51.100.23 - - [06/Nov/2026:09:12:47 +0000] "POST /login HTTP/1.1" 500 87 2026-11-06T09:13:01Z ERROR db: connection refused host=10.0.0.5 port=5432 2026-11-06T09:13:02Z WARN disk usage at 91% on /dev/sda1 ana@example.com asked for nginx/1.27.0, id 550e8400-e29b-41d4-a716-446655440000
What it means
\bA word boundary: where a word starts or ends(?:Start of a group that does not capture\dA digit (0–9){1,3}Repeat the previous item 1 to 3 times\.A literal .)End of the group{3}Repeat the previous item exactly 3 times\dA digit (0–9){1,3}Repeat the previous item 1 to 3 times\bA word boundary: where a word starts or ends
On the command line
$ grep -P '\b(?:\d{1,3}\.){3}\d{1,3}\b' file.txt- Non-capturing groups (?:…) only work with grep -P. In grep -E or sed, use a plain group.
- \d only works with grep -P. In grep -E or sed, use [0-9].
For GNU grep and sed, as on Linux. They read one line at a time.
The address bar keeps your options, so you can bookmark them. It never holds a result.
How to use it
- Type a pattern, or start from an example: IP addresses, HTTP 5xx lines, log levels, dates, UUIDs.
- Paste the text to test on, such as lines from a log. Matches light up as you type.
- Read the explanation under it, to see what each part does.
- Add a replacement to see the result, and copy the
greporsedcommand that does the same on a file.
Everything runs in your browser and your text is never sent anywhere. The page address keeps your pattern and options, and not the text, so you can share a pattern without sharing your logs.
Which flavor is this?
It runs JavaScript regular expressions, the kind your browser has. Most of what you know works the same in Python, Java, Go and PCRE, but command-line tools are a different story, and that’s where this tool helps.
| Feature | JavaScript, grep -P |
grep -E, sed -E |
grep, sed (no flag) |
|---|---|---|---|
+, ?, |, ( ), {n} |
Yes | Yes | Only as \+, \?, |, \( \), \{n\} |
\d |
Yes | No: use [0-9] |
No |
\w, \s, \b |
Yes | Yes, in the GNU versions | Yes, in the GNU versions |
Lazy *? and +? |
Yes | No | No |
| Lookahead and lookbehind | Yes | No | No |
(?:…) and named groups |
Yes | No: use a plain group | No |
\. inside [ ] |
A dot | A backslash or a dot | The same |
The commands the tool writes are compared against the real GNU grep and sed automatically, on a set of patterns. If it can’t write one, it tells you why. sed and grep -P differ on other systems: macOS has BSD sed, and its grep has no -P.
The flags
- g (global): find every match, not just the first.
- i (ignore case):
erroralso matchesERROR. - m (multiline):
^and$match at each line, not only at the start and end of the text. - s (dotAll):
.also matches a line break. - u (unicode): treat the text and pattern as Unicode, which also allows
\p{…}.
grep and sed read one line at a time, so for them ^ and $ are always about a line, and a pattern can’t span two.
Common patterns
\b(?:\d{1,3}\.){3}\d{1,3}\b an IPv4 address (allows 999.1.1.1)^\s*$ an empty or blank line^\s*# a comment line\s+$ trailing whitespace"[^"]*" text in double quotes[0-9]+\.[0-9]+\.[0-9]+ a version like 1.27.0FAQ
My pattern says it took too long
Nested repeats such as (a+)+$ can take a huge number of tries on text that doesn’t match, known as catastrophic backtracking. Here it stops after a moment, and the page stays usable. On a server, the same pattern can use a whole CPU, and take down a service if users control the input. Rewrite it so that each character can be matched only one way.
It works here, but not in grep
Look at the table above. \d is the usual reason, and grep without -E treats + and | as ordinary characters. If you need more than grep -E has, use grep -P.
How do I match a real dot or bracket?
Put a backslash in front of it: \., \[, \(. Inside [ ], most characters are already literal, so [.] is a dot in every tool.
Why does my match stop too late?
Repeats are greedy, so ".*" runs to the last quote on the line. Use "[^"]*" everywhere, or ".*?" where lazy repeats exist.
Can I use this for files?
Paste what you need, or copy the command the tool writes, and run that on the file.
Can I use it for SQL?
The syntax is close to what most databases use, as in PostgreSQL’s ~ operator. See invalid input syntax for type integer for a practical example.
Where can I find more grep and sed recipes?
In the find, grep, sed and awk Cheat Sheet.
Where can I practice grep and sed?
In the lessons on grep and sed, in a terminal in your browser.
Articles