Regex Builder
Open toolBuild a regular expression by stacking plain-English rule blocks — no regex knowledge required.
Build a regular expression without knowing regex syntax. You stack plain-English rule blocks — “some exact text”, “one or more digits”, “start of the text”, “any of these options” — and the tool writes the pattern for you, explains it in a sentence, and highlights what it matches in your sample text.
How it works
Each block turns into a small piece of a JavaScript regular expression, and the pieces are joined in the order the blocks appear. The finished pattern is shown at the top as /pattern/flags, and every change re-compiles it, so the Valid / Invalid badge and the highlighted matches are always up to date.
Blocks are a real tree: a Group holds its own blocks, and an “any of these options” block holds two or more options, each with its own blocks. That is what lets you repeat a whole sequence, or choose between two sequences.
Text you type into an Exact text block is escaped for you, so . or ( in it match those literal characters and never act as regex symbols.
How to use it
- Start from a Quick preset if one is close to what you want, or begin with an empty list.
- Under Rule blocks, choose a block type from the drop-down and click Add block.
- Fill in the block and pick how many times it should repeat.
- Add more blocks in the order the text should appear. Use the arrows to reorder and × to remove.
- Type or paste text into Test string and check the highlighted matches. Adjust until it is right.
- Click Copy next to the pattern to take
/pattern/flagsaway with you.
Options & controls
Quick presets
Each button replaces your current blocks with a ready-made rule and fills in a matching sample in Test string. Hover a button to read its description. Loading a preset discards the blocks you have built.
- URL Prefix
- The start of a web address:
httporhttps, then://. - Email Filter
- A basic email shape: letters, digits and
._%+-, then@, then a domain, a dot, and 2–10 letters. Good for a quick check, not a complete email validator. - Phone Number
- A US-style number such as
(123) 456-7890: three digits in brackets, an optional space, three digits, a hyphen, four digits. - IP Address
- An IPv4-looking address such as
192.168.0.1: three groups of 1–3 digits and a dot, then a final 1–3 digits. It does not check that each number is 255 or less.
Options (flags)
- Find all matches
- On by default. Finds every match in the text instead of stopping at the first.
- Ignore capitalization
- Treats upper and lower case as the same.
- Match line by line
- Makes “start of the text” and “end of the text” apply to every line, not just to the whole passage.
Adding and arranging blocks
- Block type drop-down + Add block
- Picks which kind of block to add, and adds it at the end of the list. A one-line hint below explains the chosen type. Inside a group or an option the button reads “Add block here” and adds to that container.
- Move up / Move down (arrows)
- Swaps a block with its neighbour inside the same list. The arrow is disabled at the top or bottom of the list.
- Remove block (×)
- Deletes that block, including anything nested inside it.
- Clear all
- Shown when there is at least one block. Removes every block but keeps the flags and the test string.
- Reset
- In the title row. Removes every block, restores the default flags, and clears the test string.
Block type: Exact text
- Text to match
- The letters, numbers or symbols to find, exactly as typed (case is respected unless Ignore capitalization is on). Special characters are treated literally.
Block type: A type of character
- Any letter (a–z, A–Z)
- One English letter. Accented letters such as é do not count.
- Any digit (0–9)
- One digit.
- A letter or a digit
- One English letter or one digit.
- A space, tab, or line break
- One whitespace character.
- Any character
- One character of any kind, except that it does not match a line break.
- A symbol (not a letter, digit, or space)
- One character that is not an English letter, a digit, or whitespace. Accented letters count as symbols under this rule.
- One of these characters…
- Reveals a box where you list the allowed characters, for example
aeiou. List each character on its own; a hyphen is taken literally, soa-zmeans “a”, “-” or “z”, not a range. - Don't match these characters
- A checkbox that appears with the custom set. Turns it around: match any character except the ones listed.
Block type: A position in the text
A position is a spot, not a character, so it has no repeat setting.
- Start of the text
- The very beginning (or the start of each line, with “Match line by line”).
- End of the text
- The very end (or the end of each line, with “Match line by line”).
- Edge of a word
- The boundary between a word character and a non-word character, such as the gap before or after a whole word.
Block type: Group
- Group
- Bundles the blocks you add inside it so the repeat setting applies to the whole bundle — for example, “a digit and a dot”, repeated exactly 3 times. It does not capture anything.
Block type: Match any of these options
- Option 1, Option 2 …
- Each option holds its own blocks; the pattern matches if any one option matches. A new block starts with two options.
- + Add another option
- Adds one more alternative.
- Remove this option
- Deletes an option. It appears only when there are three or more, because at least two are needed.
How many times (every block except a position)
- Exactly 1
- The block must appear once.
- Optional (0 or 1)
- The block may appear once or not at all.
- 0+ (Zero or more)
- Any number of times, including none.
- 1+ (One or more)
- At least once, with no upper limit.
- Custom range…
- Shows two number boxes, Minimum and Maximum. Both are whole numbers, 0 or more, with the maximum not below the minimum. While the entry is not valid a red “Enter a valid range (max ≥ min)” note shows and the previous valid range stays in effect.
Test string
- Test string
- Sample text to try the pattern on. Changing it never changes your blocks.
Reading the results
What you see
- Pattern
- The generated expression, shown as
/pattern/flags. A green “Valid” or red “Invalid regex” badge appears once there is at least one block; if it is invalid, the browser's error message is shown under it. - Copy
- Copies the whole
/pattern/flagstext. When pasting into another tool that wants only the pattern, leave off the slashes and flag letters. - In plain English
- A sentence that reads the blocks back to you, such as “Matches: the start of the text, then one or more digits.” If it does not say what you meant, the blocks are wrong.
- Highlighted matches + count
- Your test text with each match marked in yellow, and a running count such as “3 matches”. Empty states read “Add some blocks above to start matching.” or “Nothing to test yet.”
Tips & guidelines
- Without a Start or End position block, the pattern matches anywhere inside the text. To require that the whole text fits the rule (for example, that a whole field is a number), start with “Start of the text” and finish with “End of the text”.
- Read the “In plain English” line after each change; it is the quickest way to spot a wrong repeat setting.
- Test with text that should not match as well as text that should.
- For a fixed count, use a Custom range with the same minimum and maximum — “exactly 4 digits” is a range of 4 to 4.
Limits
- The builder covers common patterns only. There are no capture groups, look-ahead or look-behind, back-references, lazy quantifiers, or character ranges such as
a-z. - Repeat ranges must have both a minimum and a maximum; open-ended ranges like “3 or more” are done with 1+ or 0+ on a suitable block.
- The presets are simple starting points, not strict validators for email addresses, phone numbers, or IP addresses.
- The generated pattern is in JavaScript flavour. If you plan to use it in another language, check the differences.
Saved in your browser
Nothing. The blocks, flags and test text exist only on the page and are lost on refresh.