📝
Regex Tester
Live match highlighting · group extraction · Python export
Pattern
/ / g
Test String
0 matches
Enter a pattern above to see matches.
Run a match first, then export here.
Quick Patterns
Cheat Sheet
Share MySysAd

⚠️ IMPORTANT DISCLAIMER: The tools and scripts on this site are provided "AS IS" for educational purposes.

Review destructive commands before executing. By using this site, you assume all risk and agree to our Full Terms of Service.

Build a regex and take it to your script

Type a pattern and test text to see every match highlighted, with capture groups listed and a replace preview. When it works, export it as Python or Bash so the pattern goes straight into a log-parsing script.

Common questions

Which regex flavour does this tester use?

Your browser’s JavaScript engine. Most everyday syntax is the same in Python, but some isn’t: named groups are written (?<name>…) here but (?P<name>…) in Python, and lookbehinds in Python must be fixed-width. grep and sed default to POSIX regex, where \d doesn’t exist; use [0-9] or grep -P.

How do I match an IP address with a regex?

\b(?:\d{1,3}\.){3}\d{1,3}\b finds anything that looks like an IPv4 address, which is usually enough for logs. It also accepts 999.1.1.1; to validate properly, check each number is 0–255 in code, for example with Python’s ipaddress module.

Why does my regex match too much?

.* is greedy and takes as much as it can, so ".*" spans from the first quote on a line to the last. Use the lazy .*?, or a negated class such as "[^"]*", which is faster and clearer.

How do I use a regex with grep?

grep -E 'pattern' file uses extended regex, and grep -oP 'pattern' file (GNU grep) uses Perl-style regex and prints only the matched part. Quote the pattern in single quotes so the shell doesn’t change it.

What do the flags g, i, m and s mean?

g finds all matches instead of the first, i ignores case, m makes ^ and $ match at each line, and s lets . match newlines. In Python these are re.I, re.M and re.S; “global” is re.findall or re.finditer.

Related tools: Log Parser · Log Scrubber · All tools A–Z