Skip to content
All tools›Validators›Java Regular Expression Tester

Java Regular Expression Tester

Test Java regular expressions (java.util.regex) against any input, highlight all matches, and try replaceFirst / replaceAll.

Loading tool...

How this tester works

Browsers do not ship a Java virtual machine, so this page translates your java.util.regex pattern into an equivalent JavaScript RegExp and runs it locally. Java-only constructs are converted exactly. When a construct has no JavaScript equivalent, the result panel lists the approximations.

Java vs JavaScript regex differences

Feature Java JavaScript
Pattern in source code String literal, backslashes doubled Regex literal or new RegExp()
Whole-input match matcher.matches() Anchor with ^...$
Possessive quantifiers Supported (a*+) Not supported (approximated as greedy)
POSIX classes Supported (ASCII) Not supported
Unicode properties Scripts, blocks, categories Scripts, categories with u flag
Lookbehind Bounded length only Unbounded

Flags

Flag Inline Effect
CASE_INSENSITIVE (?i) Case-insensitive matching
MULTILINE (?m) ^ and $ match at line boundaries
DOTALL (?s) . also matches line terminators
COMMENTS (?x) Whitespace is ignored, # starts a comment
---