Regex Pattern Builder

This Regex Pattern Builder gives you three ways into a working pattern. You can pick a ready-made pattern for a common job — email addresses, URLs, hex colours, dates, times, slugs, IPv4 addresses, a strong-ish password check — and see it run against realistic sample text straight away. You can assemble your own pattern from simple options, choosing what the text starts and ends with, what characters it contains and how many times they repeat. Or you can type a pattern of your own and test it live.

Whatever pattern is in the box, the tool explains it back to you in plain English, line by line, so you can see what each part actually does before you trust it. Underneath, your text is tested as you type: matches are highlighted in place, counted, and listed with the position where each one starts. A broken pattern shows a plain inline error instead of breaking the page.

Everything runs in your browser. The text you test is never sent to a server, so you can safely try patterns against real log lines, real addresses and real form data.

A developer's desk with a monitor showing blurred code, an open notebook with hand-drawn bracket and asterisk pattern sketches, and a mug of coffee.

Regex Pattern Builder

Start from a ready-made pattern, build your own from simple choices, or type one in — then test it against your text and read what it does, in plain English. This tool uses JavaScript regular expressions, the flavour your browser runs.

Ready-made patterns

Pick a pattern above and it loads into the tester with sample text, so you can see it working before you change anything.

Build your own

Choosing anything here writes the pattern into the tester below and runs it. You can edit the pattern by hand in the tester afterwards — the builder is a starting point, not a cage.

Test your pattern

As a JavaScript literal: / /

Your text, with the matches highlighted, will appear here.

Matches

    What this pattern means

      The reading above is generated from the pattern itself, part by part — a guide to what the pattern asks for, in plain words. Everything happens in this tab: your pattern and test text are never sent anywhere, and nothing is stored when you close the page.

      How it works

      The page holds three pieces that all feed the same tester. Choosing a preset chip loads that pattern, its flags and its sample text. Choosing options in the builder card assembles a pattern from them — fixed text at the start, a character class in the middle, a repeat count and optional anchors. Editing the pattern box directly works too; whichever you changed last is what gets tested.

      The pattern and the g, i and m flags are compiled as a standard JavaScript regular expression, the dialect used by browsers and by most web code. The tester then runs the pattern over your text: with the g flag on, it finds every match; with g off, it stops at the first one. The explanation card walks through the current pattern piece by piece — character classes, quantifiers, anchors, groups and escapes — and describes each piece in ordinary words. Matching, highlighting and counting all happen locally on your device.

      How to use it

      1. Start from the preset bank if your job is a common one — email, URL, date and the rest are one tap away, each with sample text already loaded so you can see it working.
      2. Or use the builder card: tick the start or end anchor if the match must sit at an edge of the text, type any fixed text, pick a character class (letters, digits, whitespace or any character) and choose how many times it repeats.
      3. Set the flags you need: g to find every match, i to ignore upper and lower case, m to treat each line’s start and end as anchors.
      4. Paste or type your test text in the tester. Matches highlight as you type, and the count and list update with them.
      5. Read the “What this pattern does” list to confirm the pattern means what you think it means, then copy the pattern or the ready-to-paste JavaScript literal line.

      A worked example

      The tool opens on the Email preset, so this is what you see on load:

      Pattern: [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}

      Flags: g

      Test text: Email us at support@aitechtrack.com or hello@fernandflour.co.uk — personal notes go to sam.lee+news@gmail.com, not to the office.

      Result — 3 matches found:

      1. support@aitechtrack.com
      2. hello@fernandflour.co.uk
      3. sam.lee+news@gmail.com

      And the plain-English explanation the tool shows for that pattern:

      1. one character from the set [A-Za-z0-9._%+-]
      2. one or more of the previous item
      3. the literal text “@”
      4. one character from the set [A-Za-z0-9.-]
      5. one or more of the previous item
      6. a literal “.” character
      7. one character from the set [A-Za-z]
      8. the previous item, repeated at least 2 times

      The builder card produces patterns the same way. Choose “starts with”, type the fixed text order-, pick the Letters class and One or more, and the tool assembles order-[A-Za-z]+ — ready to test.

      Who it is for

      • Developers and QA testers checking a pattern against real text before it goes into code or a test case.
      • Data and ops people pulling dates, addresses or IDs out of logs and exports, who want to see exactly what a pattern catches first.
      • Students and self-taught coders learning regex, who learn faster from a pattern explained in words than from syntax tables.
      • Writers, marketers and spreadsheet users who occasionally need a pattern for validation, search-and-clean-up or form rules and do not want to memorise the syntax.

      Why use this tool

      • You do not have to start from a blank box. Eight common patterns come with honest one-line notes and realistic sample text, so a working, tested pattern is one tap away.
      • The guided builder writes the syntax for you. Anchors, fixed text, character classes and repeat counts are plain options; the pattern assembles itself as you choose.
      • Every pattern is explained in plain English. The line-by-line reading shows what the pattern in the box actually does, which is how you catch the pattern that matches more than you meant.
      • Testing is instant and private. Matches highlight, count and list as you type, and your test text never leaves your browser.

      Frequently asked questions

      Are the preset patterns guaranteed correct for production use?

      They are common starting patterns, and each one is labelled honestly. The email, date and IPv4 presets check the shape of a value — an IPv4 pattern will happily match 999.1.2.3, because the shape is right even though the address is not real. For strict validation, pair a shape check with a proper range or deliverability check in your code.

      Which regex dialect does this tool use?

      JavaScript regular expressions — the dialect that runs in every browser and in Node.js. Most patterns here also work in other dialects, but a few constructs differ between languages, so test again in your target language if it is not JavaScript.

      What do the g, i and m flags do?

      g (global) finds every match instead of stopping at the first. i (ignore case) makes letters match regardless of upper or lower case. m (multiline) makes ^ and $ match at the start and end of each line, not just the whole text — the password preset uses it to check one password per line.

      Why does my pattern show an error?

      The pattern has a syntax problem — an unclosed bracket or group is the usual cause. The error message appears under the pattern box and the rest of the page keeps working; fix the pattern and the results come back on their own.

      Does the tool test my text on a server?

      No. Matching, highlighting and the explanation all run in your browser, and nothing you paste is uploaded or stored. That is deliberate: test data is often real data.

      Can I copy the pattern into my code?

      Yes. Use the Copy button for the bare pattern, or copy the JavaScript literal line (pattern plus flags, between slashes) straight into JS code. In other languages, paste the bare pattern into your regex call.

      Are the preset patterns guaranteed correct for production use?

      They are common starting patterns, and each one is labelled honestly. The email, date and IPv4 presets check the shape of a value — an IPv4 pattern will happily match 999.1.2.3, because the shape is right even though the address is not real. For strict validation, pair a shape check with a proper range or deliverability check in your code.

      Which regex dialect does this tool use?

      JavaScript regular expressions — the dialect that runs in every browser and in Node.js. Most patterns here also work in other dialects, but a few constructs differ between languages, so test again in your target language if it is not JavaScript.

      What do the g, i and m flags do?

      g (global) finds every match instead of stopping at the first. i (ignore case) makes letters match regardless of upper or lower case. m (multiline) makes ^ and $ match at the start and end of each line, not just the whole text — the password preset uses it to check one password per line.

      Why does my pattern show an error?

      The pattern has a syntax problem — an unclosed bracket or group is the usual cause. The error message appears under the pattern box and the rest of the page keeps working; fix the pattern and the results come back on their own.

      Does the tool test my text on a server?

      No. Matching, highlighting and the explanation all run in your browser, and nothing you paste is uploaded or stored. That is deliberate: test data is often real data.

      Can I copy the pattern into my code?

      Yes. Use the Copy button for the bare pattern, or copy the JavaScript literal line (pattern plus flags, between slashes) straight into JS code. In other languages, paste the bare pattern into your regex call.

      Related free tools