$1, $2 for numbered groups · $<name> for named groupsre module$1, $2 for numbered groups · $<name> for named groupsre module⚠️ 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.
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.
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.
\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.
.* 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.
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.
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