Zahid Awais Get a free audit

Free regex tester for URLs and redirects

Test a regular expression against URLs line by line and preview redirect replacements.

By Zahid Awais · Developer and web tools · Free, private, no sign-up

Result
    LineMatchGroupsResult
    Regex Tester: what it does and an example result

    The free regex tester runs in your browser, needs no sign-up and never sends what you type anywhere.

    Quick answer

    This regex tester runs your pattern against each line of sample text, usually URLs, and shows which lines match, the highlighted match, every capture group and the result of a replacement such as /articles/$2. Rule of thumb: anchor redirect patterns with ^ and $, escape dots and question marks, and test URLs that should not match too.

    What is a regex tester?

    A regex tester is a tool that compiles a regular expression and applies it to sample strings so you can see matches before using the pattern live. It uses the browser's JavaScript RegExp engine, which is close to the syntax in Apache, Nginx, Google Analytics and Search Console, with some differences.

    How do you use the Regex Tester?

    How to use the Regex Tester: enter details, see the result and copy it
    Real screenshot of the Regex Tester with the steps marked.
    1. Enter the pattern, for example ^/blog/(\d{4})/(.+)$ for dated blog URLs.
    2. Set the flags: i for case insensitive, and tick Full match to mimic Google Analytics.
    3. Paste test URLs or text, one per line, including some that should not match.
    4. Add a replacement such as /articles/$2 to preview redirect targets.
    5. Review the table, fix the pattern until every line behaves as expected, then copy it.

    How do I test a regex for a redirect?

    Paste the old URLs one per line, write a pattern with ^ and $ anchors and capture groups, and add the target with $1 or $2 to preview each new URL. Include URLs that must not redirect, because an over broad pattern is the most common redirect mistake. Test the final rule on a staging server too.

    Which regex syntax does Google Analytics use?

    Google Analytics 4 uses RE2 regular expressions, which are case sensitive and match the full value by default, so add .* for partial matches. RE2 does not support lookaheads or backreferences. See Google's guide to regular expressions in Analytics.

    How do I filter Search Console queries with regex?

    In the Performance report, add a Query or Page filter and choose Custom (regex), then enter a pattern such as ^(what|how|why) to find question queries. Search Console uses RE2 syntax, so lookaheads are not available. Use the negative option in the filter to exclude matches instead.

    Quick reference

    PatternMatchesSEO use
    ^/blog/(.+)$/blog/any-postRedirect a folder, keep the slug
    \.(jpg|png|webp)$URLs ending in an image extensionFilter image URLs in a crawl
    ^(what|how|why|when)\bQuestion style queriesSearch Console query filter
    [?&]utm_URLs with UTM parametersFind tracking URLs to canonicalize
    ^https?://(www\.)?example\.comHTTP, HTTPS, www and non wwwNormalize hostnames

    Worked example

    Example

    Example: the pattern ^/blog/(\d{4})/(.+)$ with replacement /articles/$2 is tested on 4 URLs. /blog/2024/seo-tips becomes /articles/seo-tips and /blog/2023/link-building-guide becomes /articles/link-building-guide, while /blog/category/news and /shop/item do not match, which is exactly what the redirect needs.

    Frequently asked questions

    Why does my regex match too much?

    Usually because it is missing anchors or uses a greedy .* in the middle. Add ^ at the start and $ at the end, and replace .* with a narrower class such as [^/]+ when you only want one path segment. Always test URLs that should not match.

    Do I need to escape dots and slashes?

    Escape the dot as \. when you mean a literal dot, because an unescaped dot matches any character. Forward slashes do not need escaping in this tool or in most server configs, though JavaScript regex literals written between slashes do need them escaped.

    What do $1 and $2 mean in a replacement?

    They insert the text captured by the first and second pair of parentheses in the pattern. In Apache RewriteRule and Nginx rewrite you use the same $1 style, so the preview here maps directly to most redirect rules.

    Will a pattern that works here work in .htaccess or Nginx?

    Basic syntax such as anchors, groups, classes and quantifiers works the same. Apache RewriteRule matches the path without the leading slash in .htaccess, so ^blog/ rather than ^/blog/. Lookbehind and named groups may differ, so test on staging before going live.

    What does the RE2 warning mean?

    RE2 is the regex engine used by Google Analytics, Search Console and Looker Studio. It does not support lookaheads, lookbehinds or backreferences. If your pattern uses them, it works in this tester but will be rejected or behave differently in those Google tools.

    Is my data sent anywhere?

    No. Patterns run in your browser with the JavaScript RegExp engine, and nothing is uploaded or stored. Very complex patterns on long text can be slow, so the tool limits output to the first 500 lines.

    Sources

    Facts checked against these official pages. Read how I check facts in my editorial policy.

    Related free tools

    All 104 tools

    Redirect Map Generator

    A redirect map generator is a tool that builds the old URL to new URL table you need before a site migration.…

    Nginx Redirect Generator

    An Nginx redirect generator is a tool that turns old and new URLs into Nginx configuration such as location =…

    Want a full audit instead?

    Send your website and I will check it for you, free.

    Get my free audit
    Chat on WhatsApp
    Free updates

    Get new tools, guides and coupons first

    One short email when something new goes live: articles, free SEO tools, package updates, discounts and price alerts. No spam, unsubscribe in one click.