Regex Debugger - Debug Regex Online

Debugandtest Regular Expressions

Pattern

//g

Test String

Flags

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

Regex Debugger - Free Online Debug and Test Regular Expressions Tool

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.

Outstanding features

Real-time matching - see results immediately when typing pattern or test string
Visual highlighting - matches are marked 【】 in text
Show all matches with index position
Extractandshow capture groups ($1, $2, ...)
Toggle flags easily: g (global), i (case-insensitive), m (multiline), s (dotall)
Error messages are clear when pattern is invalid
Available examples: Email, Phone VN, URL, IPv4
Copy pattern with flags (format: /pattern/flags)
Detailed explanation of each flag
Handle 100% on browser - data security
Unlimited patternandtest string length
Supports all JavaScript regex features

Why do we need Regex Debugger?

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.

Benefits when used

  • Save time - no need to run code to test regex
  • Debug quickly - immediately see problems with patterns
  • Learn regex effectively - experiment and see realtime results
  • Understand capture groups - know exactly what each group captures
  • Test edge cases - try many different inputs
  • Avoid bugs - make sure regex works properly before using it in code

How to use Regex Debugger

  1. 1Enter the regex pattern in the Pattern box (no need for / at the beginning and end)
  2. 2Or click on an example (Email, Phone VN, URL, IPv4) to load the sample pattern
  3. 3Toggle flags as needed: g (find all), i (case insensitive), m (multiline), s (. match newline)
  4. 4Enter test string in the Test String box - multiple lines can be pasted
  5. 5View realtime results: number of matches, position (index), and capture groups
  6. 6View highlighted text with matches marked 【】
  7. 7If there is an error (invalid pattern), see the error message to fix it
  8. 8Click Copy to copy the pattern with flags (format: /pattern/flags)
  9. 9Use patterns in your code

Frequently Asked Questions (FAQ)

What are Regex flags and when to use them?

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.

What are capture groups?

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.

Why regex don't match as expected?

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.

How to match multiple lines?

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.

Does Regex limit performance?

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.

How does JavaScript regex differ from other languages?

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.

How to escape special characters?

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+/.

What is a non-capturing group?

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.

Related keywords

regex debuggerregex tester onlinetest regular expressiondebug regexregex validatorregex pattern testerjavascript regex testerregex match onlineregular expression debuggerregex capture groups

Cooperate immediately with Mavis Digital

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.

Tools Developer Tools related