Regex Tester

Test regular expressions with match highlighting

Write a regex, paste your test string, and see matches highlighted inline — no script needed to check if your pattern actually works. Captured groups show up in a table below. Handy when building extractors for scraped HTML and you need to verify the pattern catches exactly what you expect.

//

How to use

  1. 1Write a patternEnter a regular expression in the Pattern field. No slashes — just the pattern.
  2. 2Select flagsg to find all matches, i for case-insensitive, m for multiline mode (^ and $ work per line).
  3. 3Paste test textCopy an HTML fragment, page text, or API response.
  4. 4Inspect matchesIn auto mode, matches highlight as you type. Disable auto mode to run manually with Run. Capture groups appear in a separate table below.

Examples

Extract all email addresses
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
Find all emails in page text — copy the ready pattern into your scraper.
Price in various formats
\$?\d{1,3}(?:[,.]\d{3})*(?:[.,]\d{2})?
Capture a price in any format — $1,234.56 or 1234.56 — without writing multiple conditions.
URL from href attribute
href="(https?://[^"]+)"
Extract just the URL from an href attribute — the capture group returns the string without quotes or the attribute name.
Date in DD.MM.YYYY format
\b(\d{2})\.(\d{2})\.(\d{4})\b
Split a date into day, month, year — three capture groups ready for further processing.
Number between tags
<span class="count">(\d+)</span>
Pull a number from a specific tag — faster than a CSS parser for simple cases like this.

When to use for web scraping

Regular expressions in scraping are used at the post-processing stage: CSS selectors or XPath extract the right element, and regex extracts a specific value from its text. For example, an element contains "Price: $1,299" — regex extracts the number. Regex also works when HTML is poorly structured: no convenient classes or attributes, content is embedded in plain text. In Python — the re module, in JavaScript — native RegExp, in Scrapy — the re() method right after xpath() or css(). Test patterns here on real page fragments before embedding in code. One wrong character in a capture group and the parser will silently return empty strings instead of data.

FAQ

What's the difference between Python re and JavaScript RegExp?
Capture group syntax and most operators match. The main difference is syntax: Python supports named groups (?P<name>...), in JS it's (?<name>...). Basic patterns work the same in both.
My pattern finds no matches — where do I start debugging?
Start simple: remove all conditions and leave just the first few characters — confirm the basic match works. Most common causes: flag g not enabled (without it only the first match is returned), dot doesn't match newlines (need flag s), spaces in the text differ from expected. Add conditions one by one.
Why doesn't . match a newline?
By default, . matches any character except \n. Enable the s (dotall) flag so . captures everything including newlines. In Python: re.DOTALL, in JS: flag s.
How do I test a pattern on real HTML from a server response?
Copy an HTML fragment from Request Tester or DevTools (Network → Response) and paste it into the text field. Enable the g flag to find all occurrences. Matches highlight immediately, capture groups appear in the table below. Once the pattern works on real data — copy to your code.
How do I find all matches, not just the first?
Enable the g (global) flag — without it the tool returns only the first match. In Python, re.findall() or re.finditer() find all occurrences by default. In JavaScript you need the /g flag in RegExp or String.matchAll().

Related tools