Regex Tester
Test regular expressions against sample text. See matches in real-time, validate patterns, and debug regex issues.
A regular expression (regex) is a compact pattern language for matching text -- a single pattern like \d+ can find every run of digits in a document without writing a custom parser. This tool compiles the pattern you enter using JavaScript's native RegExp engine and runs it against your test string, so it validates and behaves exactly like the regex engine that powers browser JavaScript, Node.js scripts, and any tool built on the same standard. The flags you select change HOW the pattern matches: the "g" (global) flag finds every match in the string rather than stopping at the first one, "i" makes matching case-insensitive so "Cat" and "cat" are treated the same, and "m" (multiline) changes how ^ and $ anchors behave so they match the start and end of each line rather than only the start and end of the whole string. If a pattern contains invalid regex syntax -- an unclosed bracket, a malformed quantifier, or an unterminated character class -- the tool catches the resulting error and reports it directly rather than letting the page fail silently, which is one of the most common sources of confusion when hand-writing regular expressions.
Inputs
Results
Pattern Status
Enter a pattern
Matches Found
0
How to Use This Calculator
- Type your Regular Expression Pattern in the first field (e.g., \d+ to match numbers).
- Paste the Test String you want to search through into the second field.
- Choose Regex Flags — 'g' finds all matches, 'i' ignores case, 'm' enables multiline mode.
- The Pattern Status instantly confirms whether your expression is valid or shows an error message.
- Review Matches Found and the Matches list to verify your pattern captures the correct substrings.
What each input means
- Regular Expression Pattern
- Enter your regex pattern without delimiters or inline flags (e.g., \d+ to match numbers) -- choose flags separately below.
- Test String
- Enter the text to test against
- Regex Flags
- Select regex flags
How this is calculated
Worked example, using the default values
- Identify Input ParametersRegular Expression Pattern = , Test String = , Regex Flags = g = 3 input(s) provided
- Calculate Pattern StatusEnter a pattern = Enter a pattern
- Calculate Matches FoundMatches Found = 00 = 0
- Calculate MatchesMatches = string[] = [];=
- Calculate Error Message=
Engine last updated . Checked against 4 independently-derived tests — how we verify calculators.
Frequently Asked Questions
What regex flavor does this tester actually use?
It uses JavaScript's native RegExp engine, the same one built into every web browser and Node.js. That means patterns and flags behave exactly as they would in real JavaScript code -- useful for testing a regex you plan to use in a script, though other languages (Python, PCRE-based tools, etc.) have their own regex dialects with some syntax differences.
Why does the same pattern sometimes match differently depending on the flags chosen?
Flags change the matching RULES, not the pattern itself. The "g" flag controls whether matching stops at the first hit or continues through the whole string, "i" controls whether uppercase and lowercase letters are treated as equivalent, and "m" changes whether ^ and $ anchor to the whole string's boundaries or to each individual line's boundaries -- so the identical pattern can report a different match count purely from a flag change.
Why does my pattern show an error instead of just finding zero matches?
A pattern with genuinely invalid regex syntax -- like an unclosed parenthesis or bracket, or a malformed quantifier -- can't be compiled into a working regex at all, so the tool reports the underlying JavaScript error message rather than silently treating it as "no matches found." Zero matches means the pattern is valid but didn't find anything in your test string; an error means the pattern itself couldn't be compiled.
How can I test whether my pattern finds ALL occurrences versus just the first one?
Select the "g" (global) flag before running your test. Without it, JavaScript's match() function stops at the first successful match in the string; with it, the tool collects every non-overlapping match it can find, which is what most real-world text processing (find-and-replace, data extraction, validation across a whole document) actually needs.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Password Strength Calculator
Check how strong your password could be based on length and character types. See estimated time to crack.
Technology & ComputingBinary/Hex/Decimal Converter
Convert a decimal number into its binary, octal, and hexadecimal representations. Includes bit count, byte size, and ASCII character lookup.
Technology & ComputingHex Converter
Convert between hexadecimal, decimal, binary, and octal number systems. Essential for programming and computer science.
More in Technology & Computing.