Test and debug JavaScript regular expressions in real-time, with detailed match results, capture groups, and index information.
g
i
m
s
u
y
Enter both a regex pattern and input text

JSON to JavaScript Class Converter
Convert JSON data into ES6 JavaScript classes. Automatically generates nested classes and constructors to streamline your frontend development workflow.

JavaScript Events Reference Table & Compatibility List
An online reference guide for front-end developers to quickly look up JavaScript event names, categories, and browser compatibility.

AAEncode Encoder & Decoder - Obfuscate & Deobfuscate JS Online
Free online tool to encode JavaScript into the AAEncode obfuscated format or decode AAEncode strings back to readable JS code.

HTML to JS String Converter
Convert HTML code into escaped strings that can be directly embedded into JavaScript, making dynamic web content generation easier.

JSON to JavaScript Class Converter
Convert JSON data into ES6 JavaScript classes. Automatically generates nested classes and constructors to streamline your frontend development workflow.

JavaScript Events Reference Table & Compatibility List
An online reference guide for front-end developers to quickly look up JavaScript event names, categories, and browser compatibility.

AAEncode Encoder & Decoder - Obfuscate & Deobfuscate JS Online
Free online tool to encode JavaScript into the AAEncode obfuscated format or decode AAEncode strings back to readable JS code.

HTML to JS String Converter
Convert HTML code into escaped strings that can be directly embedded into JavaScript, making dynamic web content generation easier.

JJEncode Encoder & Decoder | Online JS Obfuscator
Free online JJEncode tool for JavaScript obfuscation and deobfuscation. Easily encode JS for code protection or decode strings for security analysis.
Repeatedly modifying code and running tests to debug regular expressions is inefficient. This tool runs the JavaScript regex engine directly in your browser, allowing you to verify in real-time whether your regex pattern matches the target string as expected. A Regular Expression (regex) is a pattern string used for matching and processing text. Simply input a regular expression and a test string, and the tool will output detailed information including all matches, the start and end indices of each match, and capture group contents.
Q: How do I match text containing line breaks with JavaScript regex?
A: In ES2018+, you can use the s modifier to enable dotAll mode, allowing the dot (.) to match any character including line breaks. Alternatively, you can use the [\s\S] character class.
Q: Why does my regex only return the first match?
A: You are likely missing the g modifier. For global matching, append g to the end of your expression, for example, /pattern/g.
Ensure your regex syntax is correct and special characters like ., *, and ? are properly escaped. Complex expressions can cause performance issues; avoid using patterns that might trigger catastrophic backtracking on extremely long texts. This tool runs entirely in your browser, and your input data is never uploaded to our servers.
When writing regular expressions, it is recommended to first define the text characteristics and boundary conditions you want to capture. For example, to extract a date: the pattern /(\d{4})-(\d{2})-(\d{2})/g matches "2023-10-26" and captures the year, month, and day into three separate groups. Use non-greedy quantifiers like *? to prevent over-matching, and use ^ and $ to anchor the start and end of lines to improve accuracy.