Regex Tester
Test regular expressions with real-time match highlighting, replace mode, and common presets.
Common Regex Presets
Click any preset to load it into the pattern field.
How to Use the Regex Tester
Enter Your Pattern
Type your regular expression in the pattern box between the slashes. You can also click a preset below.
Set Flags
Use the checkboxes to set flags: g for all matches, i for case-insensitive, m for multiline, etc.
See Live Results
Matches highlight in real-time — yellow for odd matches, green for even. View detailed match list below.
Try Replace Mode
Switch to Replace Mode and enter a replacement string to see the substituted output. Use $1, $2 for capture groups.
Regex Tester — Test and Debug Regular Expressions in Real Time
Regular expressions are a powerful but hard-to-write-correctly tool. A small mistake — a missing escape, a wrong quantifier, a misplaced parenthesis — can make a regex match nothing, or worse, match the wrong things. This tester lets you write a regex, see every match highlighted in real time, and test the replace function to confirm substitution works exactly as expected before putting the regex in your code.
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. The pattern /\d{3}-\d{4}/ matches strings of the form "123-4567" — any three digits, a hyphen, then any four digits. The pattern /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ is a common (if imperfect) email validation pattern. Regex is supported in virtually every programming language and most text editors.
Flags and modes
Global (g): Find all matches in the text, not just the first one. Without this flag, most regex operations stop at the first match.
Case insensitive (i): Treat uppercase and lowercase letters as equivalent. /hello/i matches "Hello", "HELLO", and "hElLo".
Multiline (m): Changes how ^ and $ work. Without multiline, ^ matches the start of the entire string and $ matches the end. With multiline, ^ matches the start of each line and $ matches the end of each line.
Dot all (s): Makes . match newline characters too. Without this flag, . matches any character except newlines.
Common use cases
Data validation: Validating user input in forms — email addresses, phone numbers, Indian PIN codes (6 digits), PAN card format (ABCDE1234F pattern — 5 letters, 4 digits, 1 letter), Aadhaar number (12 digits), GST number format, etc. Write the regex here and test it against valid and invalid examples before adding it to your code.
Text extraction: Extracting specific patterns from text — all email addresses from a document, all phone numbers from a contact list, all dates in a specific format from a log file. Test your extraction regex here with a sample of the actual data.
Find and replace in editors: VS Code, Sublime Text, and other editors support regex search and replace. Test the regex and the replacement string here, then apply the same pattern in your editor. Use capture groups ((group)) and backreferences ($1, $2) in the replacement to rearrange matched content.
Log file analysis: Server logs often need parsing — extracting timestamps, IP addresses, status codes, or response times that follow specific patterns. Test your parsing regex against a few sample log lines here before running it on a large file.
Web scraping and data cleaning: When extracting data from HTML or text sources, regex helps clean up extracted strings — removing leading/trailing whitespace, normalising date formats, extracting numbers from currency strings.
Replace mode
Switch to Replace mode to test substitution. Enter your regex, your replacement string (using $1, $2, etc. for capture group references, and $& to insert the entire match), and see the replaced output. This is exactly how JavaScript's String.replace() and String.replaceAll() functions work.
Tips
Test your regex against both valid and invalid inputs. A regex that correctly matches valid data is only half the job — it also needs to correctly reject invalid data. Test edge cases: what happens with an empty string, extra whitespace, unusual but valid formats?
Use non-capturing groups (?:...) when you need grouping for repetition or alternation but don't need to capture the content as a backreference. This keeps your capture group numbering clean.
Limitations
This tester uses JavaScript's regex engine. If you're writing regex for Python, Java, Perl, Go, or another language, there may be syntax differences — particularly around lookahead/lookbehind support, named capture group syntax, and how certain character class shortcuts work. Test in this environment for JavaScript-targeted regex; use a language-specific tool or test file for other environments.
Complex regex patterns can be slow on large input — a phenomenon called "catastrophic backtracking" can cause exponential slowdown with certain patterns and inputs. If your regex times out or causes the browser to hang, simplify the pattern or split the matching into multiple steps.
Frequently Asked Questions
This uses JavaScript's built-in RegExp engine — the same flavour used in browsers and Node.js. It's compatible with most modern programming languages for common patterns.
g = find all matches (global), i = case-insensitive, m = multiline (^ and $ match line boundaries), s = dotAll (. matches newlines), u = full Unicode support.
Yes. Use parentheses () for capture groups. In Replace Mode, reference them with $1, $2, etc. Named groups (?<name>...) are also supported and can be referenced with $<name>.
Common reasons: missing g flag (only first match found), case sensitivity (try i flag), or special characters needing escaping. In this tool, type \d directly — no double-escaping needed.
No artificial limit — all matches in the test string are found and highlighted. Very large inputs may be slow due to browser rendering, but there is no hard cap.