Test JavaScript regular expressions with live highlighting, capture groups and a replace preview.
This free Regex Tester lets you write a regular expression, paste some text and see every match instantly. It helps developers, bloggers and data cleaners who need to validate input, extract values or fix text in bulk without guessing.
Features
Live matching and highlights
Matches are highlighted in your text as you type, with a count and the position of every match.
Capture groups and named groups
See each numbered and named group for every match, so you can check that the pattern captures what you expect.
Replace preview
Try find and replace safely with $1, $& and $<name>, and copy the result when it looks right.
Flags and ready examples
Turn the g, i, m, s and u flags on or off, or load an example for emails, URLs, dates, colors and Indian mobile numbers.
How to Use
- Type your regular expression in the pattern box, without the slashes.
- Choose the flags you need. Keep g on to find every match, or turn it off to find only the first.
- Paste your test text. Matches appear highlighted on the right, and the list below shows positions and groups.
- Optional: type a replacement such as $1 or $<name> to preview the changed text.
- Press Copy regex to take the finished expression with its flags into your code.
Use Cases
Form and input validation
Check a pattern for emails, phone numbers or dates against good and bad samples before adding it to a form.
Extracting data from text
Pull URLs, prices, IDs or hashtags out of logs, exports and copied pages.
Bulk find and replace
Clean up titles, reformat dates or rename values across a long text, then copy the result.
Learning and debugging
Use the Regex Tester to see exactly why a pattern matches too much or too little, one match and group at a time.
Basic Knowledge
A regular expression, or regex, is a short pattern that describes text. Instead of searching for one fixed word, you describe a shape, such as "three digits, a dash, then four digits", and the engine finds everything that fits.
A few building blocks cover most patterns. A character class like [a-z] or \d matches one character from a set. A quantifier such as +, * or {2,4} says how many times to repeat. Anchors like ^ and $ mark the start and end of a line, and parentheses create a group that you can capture or repeat.
Flags change how the whole pattern behaves. The g flag finds all matches, i ignores case, m lets ^ and $ work on each line, s lets the dot match line breaks, and u turns on full Unicode support.
Quantifiers are greedy by default and take as much text as they can. Adding a question mark, as in .*?, makes them lazy. Be careful with nested repeats such as (a+)+, because on some inputs they force the engine to try a huge number of paths and the page can freeze.
Tips and Common Mistakes
- Escape special characters like . ? + ( ) [ ] when you mean them literally, for example \. for a real dot.
- Test with both matching and non-matching samples. A pattern that works on good input can still match bad input.
- Anchor validation patterns with ^ and $, or they will match a small piece inside a longer wrong value.
- Prefer specific classes like \d or [^\s]+ over a broad .*, which is slower and often matches too much.
Safety and Privacy
- Your pattern and text are processed in your browser with JavaScript, so they are not uploaded by this tool.
- Nothing is stored. Everything disappears when you reload or close the page.
- The page is served over HTTPS, so the connection between your browser and ranktools.in is encrypted.
- The tool does not share your input with third parties. Matching in this Regex Tester runs in a background worker that is stopped after a few seconds, so a very heavy pattern cannot freeze the page.
Frequently Asked Questions
Which regex flavor does this Regex Tester use?
It uses the JavaScript flavor, the same engine your browser uses. Most basics work the same in other languages, but features such as lookbehind, named group syntax and flags can differ in Python, PHP or Java.
What do the regex flags mean?
The g flag finds all matches, i ignores letter case, m makes ^ and $ match at every line, s lets the dot match new lines, and u enables Unicode matching. Combine them as needed.
How do I use capture groups in a replacement?
Wrap part of the pattern in parentheses, then use $1, $2 and so on in the replace box. For named groups written as (?<name>...), use $<name>. Use $& for the whole match.
Why does my pattern say it took too long?
This usually means catastrophic backtracking, often from nested repeats like (a+)+ or overlapping choices. Simplify the pattern, use more specific character classes and anchor it where you can.
Is there a limit on the text I can test?
The highlight stops after 2,000 matches, and the match list shows the first 100. Very long text works, but speed depends on your device and on how heavy the pattern is.