Regex Tester

Test JavaScript regular expressions online with live highlighting, match list and groups. Free.

50 free uses every 24 hoursUnlimited with Pro →

Private by design — your data stays on your deviceEverything runs right here in your browser. What you type is not sent to our server and is not stored.
  • Runs in your browser
  • Not stored
  • No sign-up

This regex tester lets you write a JavaScript regular expression and see every match highlighted in your test text as you type. It also lists the matches and shows capture groups, so you can check a pattern before it goes into your code. It is free and made for developers, students, analysts and anyone who cleans up text.

How do you use the regex tester?

The tool has a pattern box, a flags box and a test text area. Matches update as you type, so there is no run button to hunt for.

  1. Enter your regex and flags. Type the pattern, then add flags such as g (all matches), i (ignore case) or m (multiline).
  2. Type or paste your test text. Use a realistic sample: a few log lines, a list of emails, or a paragraph from your real data.
  3. Read the matches. Matches are highlighted in the text, and the match list shows each one with its capture groups.
  4. Adjust and repeat. Change one part of the pattern at a time and watch what the highlighting does.
  5. Check the cheat sheet. If you forget what a token means, the built-in cheat sheet is there.
How to use the Regex Tester on OneHubTools: 5 steps with a real screenshot of the tool
How to use the Regex Tester, step by step.

Need to go a step further? The Find and Replace and the JSON Formatter & Validator work the same way, right in your browser.

Your text is processed in your browser, so nothing is uploaded to a server.

What is a regex tester good for?

Regular expressions are easy to get almost right. A tester shows you the exact spot where a pattern goes wrong.

  • Form validation. Try a pattern for postcodes, phone numbers or usernames against both good and bad samples.
  • Extracting data. Pull order numbers, dates or prices out of logs, emails or exported text.
  • Find and replace. Confirm which lines a pattern will hit before you run it in your editor or script.
  • Learning. Beginners can see what each token does, one character at a time.
  • Debugging. If a pattern matches too much, the highlighting usually shows why.
Result from the Regex Tester on OneHubTools
What the Regex Tester gives you.

Regex examples you can try

Paste these into the tool to see how matches and groups look. Each one uses the g flag unless noted.

PatternTest textWhat it matches
\d+Order 66 shipped in 3 days66 and 3
(\d{4})-(\d{2})-(\d{2})Due 2025-03-14The full date, with groups 2025, 03 and 14
colou?r (flag i)Color, colour, COLORAll three spellings
^\s+|\s+$" padded text "Leading and trailing spaces
\b[A-Z][a-z]+\bSam met Priya in LeedsSam, Priya and Leeds

Tips for better regex results

  • Test with bad input too. A pattern that accepts valid data but also accepts junk is not finished.
  • Build in small steps. Start with one literal piece, confirm it matches, then add the next piece.
  • Use anchors when you need a full match. Without ^ and $, a pattern can match a small part of a longer string.
  • Prefer specific tokens over the dot. .* is greedy and often grabs more than you meant. Try [^"]* or a lazy .*? instead.
  • Use groups on purpose. Wrap only the parts you want to read back. Use (?:...) when you need grouping without capturing.
  • Include edge cases. Add empty lines, extra spaces, capital letters and odd punctuation to your sample.

Why is my regex not matching?

You forgot the g flag

Without g, JavaScript stops at the first match. If you expect several highlights and see one, add the flag.

Special characters are not escaped

Characters like . ? + * ( ) [ ] { } | \ have special meanings. To match a literal dot, write \..

Case or line breaks are getting in the way

Add i to ignore case. Add m if you want ^ and $ to work on each line instead of the whole text.

The pattern matches too much

Greedy quantifiers take as much text as they can. Make the pattern narrower, or switch to a lazy quantifier.

Is a JavaScript regex the same as other languages?

Mostly, but not always. This tool tests JavaScript regular expressions, so results match what you will get in a browser or in Node.js. Other languages differ in small ways.

  • Named groups are written (?<name>...) in JavaScript, while Python uses (?P<name>...).
  • JavaScript has no possessive quantifiers or atomic groups.
  • Escaping rules inside strings add extra backslashes in many languages, even when the regex itself is the same.

If you are writing for another language, use this page to check the core logic, then test again in that language.

Limits and specs

PriceFree
Free use50 uses every 24 hours — shared with 178 other tools in the “Basic tools” group
Where it runsIn your browser
Sign-upNot needed
Muhammad Shahwaiz Gillani
Maintained and reviewed by Muhammad Shahwaiz GillaniSoftware engineer and founder of OneHubTools · Last reviewed

How we checked it: We tested it in Chrome with real code and data, including edge cases such as empty input and very long values.

Further reading

According to MDN Web Docs, regular expressions are patterns used to match character combinations in strings; the idea dates back more than 70 years, to mathematical work in the 1950s.

Spotted a mistake or the tool did not work for you? Tell us and we will fix it.

Rate this tool

Ratings come only from signed-in users, so every rating is verified.

Only signed-in users can rate tools, so every rating shows a ✔ Verified badge.Sign in to rate

Frequently asked questions

What is a regex tester?

A regex tester is a tool that runs a regular expression against sample text and shows what it matches. It saves you from running your code again and again just to check a pattern.

Is this regex tester free?

Yes, it is free to use. You do not need to create an account to test a pattern.

Which regex flavor does this tester use?

It tests JavaScript regular expressions. Patterns that work here will behave the same way in browser JavaScript and Node.js.

Does the tool show capture groups?

Yes, the match list shows capture groups for each match. Wrap part of your pattern in parentheses, such as (\d{4}), and that part appears as a group.

Is my text uploaded anywhere?

No, your text is processed in your browser. Nothing is sent to a server.

Is there a regex cheat sheet on the page?

Yes, the tool includes a cheat sheet. Use it to look up tokens, anchors, quantifiers and groups while you build a pattern.