Regex Tester/ Real-time

Real-time match highlighting with capture group details, replace mode, and built-in common patterns. Fully local.

//
Quick:
Test String

Enter a pattern above.

Did this tool solve your problem?

What is a regex tester tool

A regex tester tool lets developers test and debug regular expressions in real time, instantly seeing match results, capture groups, and replacement effects. It supports common flags like global, case-insensitive, and multiline modes, and provides common regex templates for quick reference.

Common regex use cases

Form validation: verify email, phone number, ID formats. Data extraction: extract specific patterns from text (URLs, dates). Text replacement: batch replace pattern-matching text. Log analysis: filter log lines matching specific conditions. Web scraping: extract structured data from web pages.

Code Examples

JavaScript
const re = /(?<year>\d{4})-(\d{2})/g;
const str = "2024-03 and 2025-01";

for (const m of str.matchAll(re)) {
  console.log(m[0]);          // "2024-03"
  console.log(m.groups.year); // "2024"
  console.log(m[2]);          // "03"
  console.log(m.index);       // 0
}
Python
import re

pattern = r"(?P<year>\d{4})-(\d{2})"
text = "2024-03 and 2025-01"

for m in re.finditer(pattern, text):
    print(m.group(0))         // "2024-03"
    print(m.group("year"))    // "2024"
    print(m.group(2))         // "03"
    print(m.start())          // 0
Go
import "regexp"

re := regexp.MustCompile(
  `(?P<year>\d{4})-(\d{2})`,
)
text := "2024-03 and 2025-01"

matches := re.FindAllStringSubmatch(
  text, -1,
)
// matches[0][0] = "2024-03"
// matches[0][1] = "2024"  (year)
// matches[0][2] = "03"
Rust
use regex::Regex;

let re = Regex::new(
  r"(?P<year>\d{4})-(\d{2})"
).unwrap();
let text = "2024-03 and 2025-01";

for cap in re.captures_iter(text) {
    println!("{}", &cap[0]);  // "2024-03"
    println!("{}", &cap["year"]); // "2024"
    println!("{}", &cap[2]);  // "03"
}

Frequently Asked Questions

What do the regex flags do?
g (global) finds all matches instead of just the first; i (ignore case) makes matching case-insensitive; m (multiline) makes ^ and $ match line boundaries; s (dotAll) makes . match newlines too.
How do I use capture groups in replace?
Wrap parts of your pattern in () to create capture groups, then reference them as $1, $2, etc. in the Replace field. For example, pattern (\d{4})-(\d{2}) with replacement $2/$1 turns 2024-03 into 03/2024. Named groups (?<name>…) can be referenced as $<name>.
What does the match index mean?
The index is the zero-based character offset where the match starts in the original string. This is useful in code — it corresponds directly to the index returned by String.prototype.exec() or match().
How do I match Unicode / CJK characters?
For Chinese characters, use [\u4e00-\u9fff]. For a broader range: [\u4e00-\u9fff\u3400-\u4dbf]. With the u flag enabled, you can use Unicode property escapes like \p{Script=Han} to match all Han characters.
What are lookahead and lookbehind assertions?
They match positions, not characters: (?=…) positive lookahead — the right side must match; (?!…) negative lookahead — the right side must not match; (?<=…) positive lookbehind — the left side must match; (?<!…) negative lookbehind — the left side must not match.
Why does my regex cause an infinite loop?
When using the g flag, a pattern that can match empty strings (like a* or .*) won't advance lastIndex after an empty match, causing an infinite loop. This tool automatically advances lastIndex after empty matches and caps execution at 2000 matches.