Regular Expression Tester
Run a JavaScript regular expression and list matches and groups.
Read the guideRun the tool
The calculation runs in your browser. This tool does not send your input to JVR Software.
More information
Back to the toolWhat it is and when to use it
Regular Expression Tester tries a JavaScript regex against sample text and reports matching text, positions and captured groups. Use it to debug extraction rules for a predictable format, check edge cases for form validation, or learn how a pattern behaves before putting it into a program.
How it works
The tool builds a JavaScript RegExp and searches for all matches. It accepts a plain pattern or slash-delimited notation with flags. Capturing parentheses save part of a match, and named groups can make the report easier to read. Match positions refer to JavaScript string offsets.
How to use it
- Use representative text containing examples that should and should not match.
- Enter your pattern, including flags such as i only when needed, then run the test.
- Inspect the actual matched text and groups before assuming the pattern validates the entire input.
Worked example
Use AB-12 and ZZ-345 with the pattern ([A-Z]+)-([0-9]+). You should see each code with captured letters and digits. Add ^ and $ when testing a rule intended to match one complete value instead of a substring.
To check a proposed rule, keep one sample that should match, one that should fail, and one with punctuation near the expected boundary. Look at both the captured text and the offset. When embedding the pattern in a programming language, review how its own string syntax escapes backslashes.
Reading the result
No matches can be a valid result. A syntax error means the pattern or flags are invalid. Positions count UTF-16 code units, so an emoji before a match can move the index farther than the number of visible characters suggests.
Common mistakes and limits
JavaScript syntax differs from some server regex engines. Keep sample sizes modest and avoid unnecessarily nested repetitions that can take a long time on some inputs. A pattern that works on a few examples is not a substitute for validating edge cases in your actual application.
