Regex Pattern Builder
This builder makes the structure of a small JavaScript regular expression visible instead of hiding it behind a generated opaque string.
Workspace
What Is the Regex Pattern Builder?
The Regex Pattern Builder is a regex tester: you type a regular expression (regex) — a compact pattern that describes a set of text strings, such as "one or more digits" or "something shaped like an email address" — and test it against sample text to see every match. Developers use regexes to validate input, find text, and extract pieces of a string.
A few building blocks cover most patterns: d means a digit, w means a word character (letter, digit, or underscore), . means any character, + means one or more of the previous item, * means zero or more, ^ anchors to the start of the string, and $ anchors to the end. So d+ means "one or more digits".
How to Use the Regex Pattern Builder
- Type your pattern in the Regular expression field, for example
d+for one or more digits. - Set the Flags field if you need them: it starts as
g(find all matches). Useito ignore case,mfor multi-line,sso.matches newlines,ufor Unicode, oryfor sticky matching. - Paste or type your sample text in the Test text field.
- Click Test pattern. The result shows the total number of matches, then each match with its position in the text (and any captured groups).
- Test against strings that should not match too, such as an empty string or text with the right shape but wrong characters.
- An invalid pattern shows an error instead of matches — for example, an unclosed bracket. Fix the pattern and test again.
Worked Example
Input: pattern d+, flags g, test text Order 42, total 199. Observed tool output: Total matches 2 — match 1 “42” at index 6, match 2 “199” at index 16.
Against no digits here the same pattern returns “No matches found.” — which is a real result, not an error. Check any pattern you use against examples like these rather than trusting a single test.
Limitations
- The tool tests a pattern you write; it does not assemble one for you or explain what each token means. If you are learning regex, build the pattern from the blocks in the introduction and test each step.
- Regex syntax differs between languages and tools: JavaScript, Python, and grep share most basics but differ on lookarounds, named groups, and some escapes.
- A pattern that matches what you want can still match things you do not want.
d+matches the42insideabc42, not only standalone numbers. - Greedy quantifiers match as much as possible, which can swallow more text than intended; lazy quantifiers such as
+?match as little as possible. - Regexes are a poor tool for deeply nested or structured formats such as full HTML parsing. Use a proper parser for those jobs.
- Never use an untested regex from the internet to validate security-sensitive input. A wrong pattern can accept malformed data or reject legitimate input.
Frequently Asked Questions
What does d+ mean? It means one or more digit characters in a row. d matches a single digit (0-9), and + means one or more of the preceding item.
What does the Flags field do? It sets the regex flags: g finds all matches (the default), i ignores case, m treats ^ and $ as line anchors, s lets . match newlines, u enables Unicode mode, and y makes matching sticky. Any other characters you type there are ignored.
How do I match a whole string, not just part of it? Anchor the pattern with ^ at the start and $ at the end. ^d+$ matches a string made entirely of digits, while d+ alone also matches digits inside a longer string.
How do I match a literal dot or plus sign? Escape it with a backslash: . matches a literal period and + matches a literal plus. An unescaped . matches any character, and an unescaped + is a quantifier, not a character.
Related Tools
From the Blog
How to Split a Bill Fairly (With Tip and Tax, Without the Awkward Maths)
Quick Answer Agree the method before ordering, split the food by what each person ordered, and split tax and tip in proportion…
Read article →How to Use the Pomodoro Technique to Actually Finish Your Work
Most productivity advice tells you what to do and leaves the when to you. That is exactly where the day falls apart.…
Read article →How to Merge PDF Files Into One Document (Without Losing Pages)
You have five PDFs. Your bank wants one file. Your university wants one file. Your client wants one file. Merging them is…
Read article →