Build
Regex Builder
Write a regular expression or assemble it from blocks, read what each part means, and test it live on your own text, with snippets for JavaScript, PHP and Python.
- Runs in your browser
- Free to run
- You enter
- A pattern typed in the editor or built from blocks, flags, and one or more test texts.
- You get
- Highlighted matches with groups, a replace, split or line-by-line result, a plain explanation and code to copy.
- A good result
- Every should-match test case passes, no should-not-match case matches, and no flavour warning for your language.
On this page
#What it is for
Write a pattern for validation, search or cleaning without composing it blind: for example to check a column of company IDs, pull UTM parameters out of links or trim spaces from every line.
#What you enter
- The editor with syntax colours and matching brackets, and the block list beside it. Both show the same pattern: type in one and the other follows. Blocks can be dragged, nested into groups and options, duplicated or removed.
- Flags: g, i, m, s, u and y, each with a short explanation.
- Flavour: JavaScript, PHP (PCRE) or Python. Parts that the chosen language reads differently or does not support get a warning.
- Test text: several samples in tabs, plus test cases marked "should match" or "should not match".
- Library: 34 ready patterns in groups (contact, Czech, web, network, date and time, text and numbers), among them email, Czech phone, PSČ, IČO, DIČ, Czech bank account and IBAN, rodné číslo shape, URL, UTM parameter, IPv4 and UUID. Each comes with sample text and test cases.
#How it works
Everything runs in your browser. The pattern is tested in a separate worker as you type, and a run that takes longer than 1.5 seconds is stopped (a pattern with nested repetition such as (a+)+ can backtrack for ages), so the page never freezes. At most 2,000 matches are listed.
- Matches
- Every match highlighted in the text, each group in its own colour, and a table of matches with their groups and positions.
- Replace
- The text after a replacement, with
$1and$<name>references. - Split
- The pieces the pattern cuts the text into.
- Lines
- Each line tested on its own, with a tick or a cross.
What it means explains the pattern token by token in plain words; pointing at a part lights up the same token in the editor and the block. Use it in code gives a ready snippet for the chosen language. The cheat sheet lists the syntax with examples.
#Reading the results
The status line says how many matches were found and how long the run took, or why the pattern is invalid. Test cases show pass or fail each; fix the pattern until all pass. Flavour warnings name the part that will behave differently in the chosen language.
Undo and redo keep every step (Ctrl+Z, Ctrl+Shift+Z). Share link puts the pattern, flags and sample into the address, so a colleague opens the same thing. Saving (Ctrl+S) or copying adds the pattern to the history panel.
#Example
[?&](?<key>utm_[a-z]+)=(?<value>[^&#\s]*)Paste a list of links into the test text and the Matches tab lists every utm_* key with its value in the named groups.
#Limits and gotchas
- The tester runs JavaScript regular expressions. PHP and Python get warnings for known differences, not a run in that language.
- Export saves the pattern, flags, samples and test cases as a JSON file (format version 3). Import also reads files from the older builder (versions 1 and 2) and turns them into the new form. An exported file is available for download for 5 minutes.
- A share link holds the sample text too, so keep private data out of a link you send on.