Debugandtest Regular Expressions
g - Global
Find all matches, don't stopping at the first match
i - Case Insensitive
Does not distinguish between flowers
m - Multiline
^ and $ match the beginning/end of each line
s - Dotall
. match both newlines
Free online debugandtest Regular Expressions (Regex) tool. Real-time matching with visual highlighting - see matches immediately as you type. Show all capture groups with index. Toggle flags easily: global (g), case-insensitive (i), multiline (m), dotall (s). Available examples for email, phone, URL, IP. Copy pattern with flags. Completely processed in the browser - patternanddata don't sent to the server. Useful for developers when writing anddebug regex for validation, parsing, text processing.
Regular Expressions (Regex) is a powerful tool for pattern matching and text processing, but also notoriously difficult to write and debug. A complex regex can take hours to write correctly. Regex Debugger helps you: See matches immediately as you type - Are no need to run code to test. Understand how regex works with highlighting. Debug capture groups - see exactly what each group captures. Test with many different inputs quickly. Learn regex - see examples and experiment. This tool is especially useful when writing regex for form validation (email, phone, password), parsing logs, extracting data from text, complex orsearch & replace.
Flags change how regex works: g (global) - finds all matches, not stopping at the first match. i (case-insensitive) - case-insensitive, 'A' matches 'a'. m (multiline) - ^ and $ match the beginning/end of each line, not just the beginning/end of the string. s (dotall) - mark. match both newline characters. Commonly used: gi for search all case-insensitive, g for replace all.
Capture groups are the pattern part in parentheses (). When regex matches, the content matched by each group is 'captured' and can be accessed separately. For example, pattern '(\\d{2})/(\\d{2})/(\\d{4})' match 'December 25, 2024' will capture $1='25', $2='12', $3='2024'. Groups are useful for extracting parts of matches or for use in replacement.
Common mistakes: Forgetting to escape special characters (. * + ? ^ $ requires \\). Missing g flag so only match the first time. Pattern is too strict (use ^ $ when not needed). Does not include whitespace. Character class is wrong ([a-Z] is not valid, must be [a-zA-Z]). Use this tool to debug step by step.
Turn on flag m (multiline). Then ^ matches the beginning of each line (not just the beginning of the string), $ matches the end of each line. If you want. match both newlines, turn on the s (dotall) flag. Or use [\\s\\S] instead of . to match every character including newline.
Have. Complex regex with lots of backtracking can be very slow (catastrophic backtracking). Avoid nested quantifiers like (a+)+. Avoid .* when a more specific pattern can be used. Test with large input to ensure performance. This tool runs in the browser so you will immediately see if the regex is too slow.
JavaScript regex has some differences: There is no lookbehind in ES5 (available since ES2018). There are no named groups in ES5 (available since ES2018). Flag s (dotall) is only available since ES2018. There is no x flag (verbose). If using this regex in Python, PHP, Java, you may need to adjust the syntax.
Special characters in regex: . * + ? ^ $ { } [ ] \\ | ( ). To match literal characters, add \\ in front. For example: match dot using \\., match $ sign use \\$. In JavaScript string, \\ is also an escape character so \\\\ is needed. For example: new RegExp('\\\\d+') or /\\d+/.
Non-capturing group (?:...) group pattern without capturing. Useful when you need to group to apply quantifier but don't need to extract value. For example: (?:https?://)? match optional http:// or https:// without creating a capture group. Help keep $1, $2 for important groups.
We not only design websites, but also help businesses build strong digital brands. Providing comprehensive website design services from design to SEO optimization. Please contact Mavis Digital immediately to create breakthrough, effective and sustainable technology solutions for your business in Ho Chi Minh.
Create .envand.env.example file for project.
Generate .gitignore for Node.js, Python, Java.
Create mock JSON data for API testing.
Format and analyze API response.
Test REST API: GET, POST, PUT, DELETE.
Convert Binary, Hex, Base32.
Base64 encoding/decoding.
Convert Decimal, Binary, Hex.
Create visual CSS box-shadow.
Calculate Linux file permissions.
Check WCAG accessibility.
Generate random color palette.