Java Regex Tester
Test java.util.regex patterns against the real JDK engine — compiled to WebAssembly, in your browser.
Free, no signup — runs entirely in your browser on RegexTester.dev.
Annotation
Unable to parse pattern
gglobal: Don't return after first matchiignore case: Case insensitive matchingMatch Results
0 matchesNo matches found
Quick Reference
Test your Java regex against the real engine below
Java regex: what makes it different
- Class intersection
- [a-z&&[^bc]] — character-class set operations are unique to Java (and && needs escaping inside brackets).
- \k<name> backrefs
- Named groups are (?<name>X); reference them in the pattern with \k<name> and in replacement strings with ${name}.
- Possessive quantifiers
- Java supports possessive a*+ and atomic (?>…) groups for backtracking control — unlike JavaScript or Python < 3.11.
- No delimiters
- Unlike PHP or Perl, Java patterns are plain strings — mind Java string escaping ("\\d" in source = \d in the pattern).
Java's java.util.regex (Pattern/Matcher) is a Perl-inspired flavor with its own quirks: named groups are (?<name>…) but backreferences to them use \k<name>, character-class intersections [a-z&&[^bc]] exist nowhere else, and constructs like \G and \Q…\E quoting behave differently than in other languages.
A classic pain point: a pattern that works in an online JavaScript tester fails in Eclipse or production Java. The only reliable way to test Java regex is against the Java engine itself — so this page runs the real JDK regex engine compiled to WebAssembly.
Java regex FAQ
Why does my regex work online but not in Java?
Usually one of three reasons: (1) the online tester simulated JavaScript or PCRE behavior instead of the Java engine; (2) Java string escaping changed the pattern ("\d" in source code must be written "\\d"); or (3) the pattern uses constructs Java treats differently, such as \p classes or character-class intersections. Testing against the real Java engine — as this page does — eliminates all three.
Does Java regex support named groups?
Yes: define with (?<name>X), backreference inside the pattern with \k<name>, and access in code via matcher.group("name"). Note the syntax differs from Python's (?P<name>X).
Does Java regex support lookbehind?
Yes — bounded lookbehind (?<=…) and (?<!…) are supported, and Java allows different fixed lengths across alternatives inside one lookbehind. Unbounded lookbehind (e.g. (?<=a*)) is not supported.