Regex Tester
Test regular expressions with live match highlighting. Supports all JavaScript regex flags. Free, private, browser-based.
How to Use
- 1. Enter your regular expression pattern in the pattern field.
- 2. Toggle flags as needed (g for global, i for case-insensitive, etc.).
- 3. Paste your test string. Matches are highlighted in real time.
- 4. View match list below with index positions and capture groups.
About This Tool
Regular expressions (regex) are one of the most powerful tools in a developer's toolkit. They allow you to search, validate, extract, and transform text using compact pattern syntax. Mastering regex can dramatically reduce the amount of string manipulation code you write.
This tester uses JavaScript's built-in RegExp engine, which supports all standard regex features: character classes (\d, \w, \s), quantifiers (*, +, ?, {n,m}), anchors (^, $, \b), groups (capturing and non-capturing), lookaheads, lookbehinds, and named capture groups.
As you type your pattern and test string, matches are highlighted in real time and listed below with their index positions and any captured groups. The error display helps you quickly spot syntax errors in your pattern.
This tool runs entirely in your browser. No network requests are made. It's available offline once the page is loaded.
You may also find our Find & Replace Text, JSON Formatter, and SQL Formatter helpful.
Frequently Asked Questions
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. It's used for string searching, validation, parsing, and text manipulation in virtually every programming language.
What does the "g" flag do?
The global (g) flag makes the regex find all matches in the string, not just the first one. Without it, the regex stops after the first match.
What does the "i" flag do?
The case-insensitive (i) flag makes the regex match regardless of letter case. For example, /hello/i matches "Hello", "HELLO", and "hello".
What are capture groups?
Capture groups (created with parentheses) let you extract specific parts of a match. For example, /(d+)-(d+)/ on "2024-01" captures "2024" in group 1 and "01" in group 2.
Which regex flavor does this tool use?
This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript specification. It supports most standard regex features including character classes, quantifiers, lookaheads, and named capture groups.
Was this tool helpful?
Guide
How to test a regular expression against sample text
The regex tester lets you type a pattern, switch flags on and off, paste sample text and immediately see which parts match. Matches are highlighted in yellow inside a preview of your text and listed one by one with their starting index and any capture-group values. The pattern goes straight to your browser's built-in JavaScript RegExp engine, so what you see is how the same pattern behaves in JavaScript.
This is the JavaScript (ECMAScript) flavour, close to but not identical with Python, PCRE, Java or .NET. Everyday patterns carry across, but possessive quantifiers, atomic groups and the \A and \Z anchors do not exist in JavaScript. Re-test in the target language if it is not JavaScript.
Step by step
- Type your pattern in the Regular Expression field. The slashes on either side are drawn for you, so do not type them.
- Use the four flag buttons: Global (g), Case-insensitive (i), Multiline (m) and Dot all (s). Global is on at the start, and active flags show in pink after the closing slash.
- Paste your sample into the Test String box.
- Look at the Matches count and the highlighted preview. Nothing is shown until both the pattern and the test string have content.
- Scroll the list beneath. Each entry shows its number, the matched text, its index (the zero-based position from the start) and a Groups line with each capture group in order.
- If the pattern is malformed, a red message gives the engine's error, such as Unterminated group, and the match list empties. Correct the pattern and carry on.
When this is useful
- Drafting a check for a form field, such as a ten-digit mobile number or a PAN-style code, before wiring it into code.
- Pulling order numbers or dates out of a pasted email or log with capture groups.
- Debugging a pattern that behaves differently in your app by toggling case sensitivity or multiline mode.
- Scanning log lines that start with a keyword, using ^ with the multiline flag.
Worked example: Extracting Indian mobile numbers from a message
Pattern: (?:\+91[- ]?)?([6-9]\d{9}) with Global on. Test string: Call Meera on 98765 43210 or 9123456789; office +91-8012345678. Ignore 1234567890 and 5551234567. The tool reports Matches: 2. Match #1 is 9123456789 at index 29, with group 9123456789. Match #2 is +91-8012345678 at index 48, with group 8012345678, so the optional prefix is part of the match while the group holds just the ten digits. Not matched: 98765 43210, because the space splits the digits, and 1234567890 and 5551234567, which begin with digits outside 6 to 9, a common rule of thumb for Indian mobile numbers and not a complete validation.
Tips for better results
- Start narrow and widen. Begin with the literal text you want, then replace parts with classes such as \d or \w one at a time, watching the match count.
- Turn on m when using ^ or $ on several lines. Without it they only match the start and end of the whole string.
- Turn on s when a dot needs to cross line breaks. Without it the dot stops at the end of a line.
- Wrap numbers in \b word boundaries so matches are not cut out of the middle of longer digit runs.
Common mistakes
- Forgetting Global. Without g only the first match is listed even if the text has several.
- Typing slashes or flags into the pattern field. Entering /abc/i searches for those characters literally. Type abc and click the i button.
- Expecting flags the tool does not offer. There is no u flag, so \p{L} does not match letters, and there are no y, d or v flags. Use explicit ranges such as [\u0900-\u097F] for Devanagari letters.
- Writing nested repeats like (a+)+$. On a long non-matching string they can run for a very long time, and because the tool re-runs on every keystroke the tab may freeze. Simplify the pattern and start with short samples.
- Treating a shape match as proof a value is real. A PAN-style pattern accepts ABCDE1234F even though it is only a sample; a regular expression checks format, not validity.
Your files and privacy
Your pattern and test string are handled by the RegExp object in your browser. The tool's code makes no network request and does not store or log either field, and reloading the page clears them. Even so, avoid pasting real personal data you would not want visible on your screen.
Frequently asked questions
Which regex flavour does this use?
JavaScript (ECMAScript), via the RegExp engine in your own browser. It supports lookaheads, lookbehinds in current browsers, named groups and lazy quantifiers, but not possessive quantifiers, atomic groups, \A or \Z. Advanced patterns may behave differently in Python or PCRE.
What do the four flags do?
g finds every match instead of just the first. i ignores letter case. m makes ^ and $ match at the start and end of each line. s lets the dot match line breaks as well.
What does the index number mean?
It is the zero-based position where the match begins in the test string, counting every character including spaces and line breaks. A match at index 0 starts at the very first character.
Why do I see empty or extra matches?
Patterns that can match nothing, such as a*, produce empty matches wherever no a is present. On baac, a* gives four matches: empty at index 0, aa at 1, and empty at 3 and 4. Use a+ instead.
How are capture groups shown, and can it replace text?
Groups appear in the order their opening parentheses occur, in a Groups line under each match. Optional groups that did not take part show up empty, and named groups are listed by value only. The tool only finds matches and has no replacement field.
Guide reviewed 2026-10-11 by the useToolify team.
More Tools
Related Developer Tools
JSON Schema Generator
Meta Tags Generator
JSON Formatter
SQL Formatter
You Might Also Like