Skip to content

Regex Tester

Takes about a minute. You hear back from me personally.

Prefer Saad Raza SEO on Google Add this site as a preferred source and Google will show more of my SEO and AI search guides when you search.

Add saadrazaseo.com as a preferred source on Google
Free tool

Runs in your browser. Nothing you enter is uploaded or stored.

Loading the tool...

To test a regular expression, type your pattern into the free Regex Tester above, paste the text to search and press Test. It highlights every match in the text, lists each one with its position and capture groups, and can show the result of a replacement such as swapping $1 and $2. A ready-made pattern menu covers emails, URLs, IP addresses, hex colours, dates, HTML tags and prices, and bulk mode tests each line separately and reports the line number of every match. It uses JavaScript regular expressions and runs in your browser.

Last updated: 11 November 2026. Written by Saad Raza.

Key takeaways

  • A regular expression, or regex, is a compact pattern for finding and changing text. SEOs use them in Google Search Console filters, Google Analytics, redirect rules, log analysis, crawl tools and spreadsheets.
  • Flags change how a pattern behaves: g finds all matches, i ignores case, m treats each line as a separate start and end, s lets the dot match line breaks, and u turns on full Unicode.
  • Capture groups, written in parentheses, let you pull out part of a match and reuse it in a replacement as $1, $2 and so on.
  • Regex dialects differ. This tester uses JavaScript rules, which are close to what Search Console, Analytics and many tools use, but PHP, Python and server redirect rules can differ in details.
  • Always test a pattern on real examples, including ones that should not match, before you use it in a redirect or a filter.
  • Everything runs in your browser. Log lines and URLs are not uploaded.

Where SEOs use regular expressions

Regex turns a job that takes an hour of manual work into a one-line pattern. In Google Search Console you can filter queries or pages with a custom regex, for example to find all questions or all pages in one folder. In Google Analytics you can build segments and filters. In crawl tools you can include or exclude URLs and extract data such as prices or schema values. In spreadsheets and editors you can clean lists of URLs. In server configuration, redirect rules use patterns to map thousands of old URLs to new ones.

The downside is that a small mistake can match far more than you intended. A redirect rule that is too greedy can send half a site to the wrong page. A tester lets you see exactly what a pattern does before it goes live.

How to use the Regex Tester

  1. Enter the pattern without the surrounding slashes, or pick a ready-made one from the menu.
  2. Set the flags. The default is g, which finds every match. Add i to ignore case.
  3. Paste the test text.
  4. Tick Test each line separately to run the pattern on every line on its own, for a list of URLs or log entries. The results then include the line number.
  5. Optionally enter a replacement, using $1, $2 and so on for groups, to see the transformed text.
  6. Press Test. You get the number of matches, the highlighted text, a table of matches with their positions and groups, a downloadable list of matches and the replaced text.

If the pattern is not valid, the tool shows the error message from the browser, such as an unterminated group, so you can fix it. If nothing matches, it suggests checking the flags and the text.

A cheat sheet of common pattern parts

PatternMeaningExample
.Any one character except a line breakc.t matches cat and cut
d w sA digit, a word character, a spaced+ matches 2026
[abc] [a-z]One character from a set or range[0-9a-f] matches a hex digit
* + ?Zero or more, one or more, zero or onecolou?r matches color and colour
{2,4}Between 2 and 4 repeatsd{2,4} matches 11 or 2026
^ $Start and end of the text, or of a line with the m flag^/blog/ matches paths that start with /blog/
( ) and (?: )A capture group, and a group that is not captured(d+)-(d+) captures two numbers
|Orcat|dog matches either
bA word boundarybseob matches the whole word seo
(?<=x) (?=x)Look behind and look ahead(?<=$)d+ matches digits after a dollar sign

Special characters such as . ? + * ( ) [ ] { } | ^ $ and the backslash need a backslash in front of them when you mean the literal character, for example . for a full stop.

A worked example

The example uses the email pattern from the menu on four lines of text containing two email addresses, two web addresses, two IP addresses, a colour, a date and a price. With the g flag, the tester finds 2 matches: hello@saadrazaseo.com at position 9 and saad@example.org at position 34, and the text is highlighted in place. Switch the pattern to the URL option and it finds both web addresses, and with the IPv4 option it finds 192.168.1.10 and 10.0.0.255.

Now try a replacement. With the pattern (w+)@(w+).com and the replacement $2:$1, the text a@b.com becomes b:a. The same idea lets you reorder parts of a URL, strip a tracking parameter or turn a list of old paths into a redirect map. The final output appears in a box that you can copy.

Regex for redirects and URL work

  • Test with matches and non-matches. Paste ten URLs that should match and ten that should not, then use the per-line mode to confirm the result for each.
  • Anchor your patterns. Start with ^ and end with $ so that /shoes does not also match /shoes-sale.
  • Avoid greedy surprises. The pattern .* grabs as much as it can. Use a more specific class such as [^/]+ to match one path segment.
  • Escape dots. An unescaped dot in a domain matches any character.
  • Check the dialect. Apache and Nginx rules, Search Console and Analytics each have small differences, so confirm in the real tool. Build Apache rules with the htaccess redirect generator and test the result with the redirect checker.
  • Encode first if needed. URLs with spaces or accents may be percent-encoded, so decode them with the URL encoder and decoder before matching.

You can also use regex to pull data out of pasted lists: extract all the email addresses, or all the numbers, from a block of text and download the matches. For lists with repeats, run the remove duplicate lines tool on the output. If you are planning a large migration with many redirect rules, an SEO audit helps you map and check them.

Limits

The tester uses the regular expression engine of your browser, which is JavaScript. Some features from other languages, such as possessive quantifiers, atomic groups and certain inline flags, are not available, and lookbehind support depends on your browser version. A pattern with nested repetition on long text can take a long time to run, a problem known as catastrophic backtracking, and since the page cannot stop it, test on a short sample first. The tester stops after 5,000 matches and shows the first 500 in the table, while the download contains all the matches found. The ready-made patterns are starting points and are not perfect: an email pattern, for example, cannot decide whether an address really exists. Everything is processed in your browser, and nothing is sent to a server.

Questions about the Regex Tester

What is a regular expression?

It is a pattern that describes a set of strings. You use it to find, extract or replace text, for example all the email addresses in a document or all the URLs in one folder of a site.

What do the g, i and m flags do?

The g flag finds all matches instead of only the first. The i flag ignores upper and lower case. The m flag makes ^ and $ match the start and end of each line instead of the whole text.

How do I use capture groups in a replacement?

Put part of the pattern in parentheses, then write $1 for the first group, $2 for the second and so on in the replacement. For example, (w+)@(w+) with $2:$1 swaps the two parts.

Will my pattern work in Google Search Console?

Usually for simple patterns, but Search Console uses a different engine with its own limits. Test here, then confirm in Search Console before relying on it.

Is my text uploaded?

No. Matching runs in your browser, so URLs, logs and other private text stay on your device.

If you want help with redirects, filters and technical SEO, see my SEO services or ask for a free audit. You can also browse the other free technical SEO tools.

Got your results? Let’s turn them into a plan

Tools show the issues. I will tell you which ones matter most and how to fix them.

Your details are only used to reply to your request. No spam.

Grow my trafficCall