We use cookies.This website uses essential cookies to operate core features. With your consent, we also use analytics cookies to understand traffic and improve the service. For more details, see our .
Was this tool helpful to use?
Your feedback helps us make it better
Preview common Java-style pattern inputs using a browser JavaScript regex engine.
CASE_INSENSITIVE / i
MULTILINE / m
DOTALL / s
UNICODE_CASE
UNICODE_CHARACTER_CLASS
COMMENTS / x
LITERAL
Please enter a regular expression and text to match.
Overview
Understand what the tool solves, how it works, and the boundaries of its data.
Use this page to try a regular-expression pattern against sample text in a browser and inspect what it finds. In Match mode, it highlights each match and lists its position, length, numbered capture groups, and named groups. A capture group is a parenthesized part of a pattern whose matching text is reported separately. In Replace mode, enter replacement text to preview the changed sample; choose whether to replace every match or only the first.
The name describes the patterns and flag concepts you may be preparing for Java. The preview itself runs with the browser's JavaScript regular-expression engine. It is not a Java runtime and does not execute java.util.regex.Pattern. Some familiar expressions work similarly, but syntax and matching details can differ.
Settings include case-insensitive, multiline, dotall, Unicode case, Unicode character class, comments, and literal modes. Multiline affects how ^ and $ recognize line boundaries; dotall changes whether . can match a newline. Comments mode removes whitespace and hash comments before testing, while literal mode escapes pattern metacharacters. The interface maps these options only partially onto browser flags and preprocessing; the Unicode options, for example, share a JavaScript Unicode flag. Do not infer full Java flag semantics from a successful preview.
Java source code adds another layer of escaping: a regex typed directly into this page is the pattern text, whereas a Java string literal may need doubled backslashes so the compiler passes the intended backslash to the regex engine. Oracle's Pattern API documentation describes Java syntax and string-literal escaping. The ECMAScript specification describes the browser engine's own syntax and flags. Both were checked October 2, 2026.
Guide
Follow the workflow and verify inputs and outputs with practical examples.
Type the regex without Java source-code quotation marks. For instance, ([A-Z]+)-([0-9]+) can find identifiers such as A-204 and capture the letter prefix and digits separately.
Paste a short excerpt into the text field. Include examples that should match and nearby examples that should not, such as A-204, B-9, and lower-3.
Match mode shows highlighted hits and their groups. In Replace mode, enter replacement text, then leave Replace All enabled to preview every hit or turn it off to preview only the first.
Toggle one setting at a time, then review the match count, positions, lengths, and group values. An invalid-pattern result means the browser engine rejected the current pattern. A transformed-pattern indicator means comments or literal preprocessing changed the entered pattern before execution.
Use cases
See how the tool fits into real work and everyday tasks.
A developer can try a pattern against representative log lines and check whether each capture group contains the intended field before implementing a parser in Java.
A data-cleaning workflow can preview a replacement on a small sample and compare first-only with replace-all behavior before changing a larger dataset.
A learner can change multiline or dotall settings and observe how highlights and captures change. Use a target-JDK check afterward when the goal is to understand Java behavior.
Q&A
Find concise answers to common questions and confusing cases.
No. Matching and replacement run through the browser's JavaScript regular-expression engine. It is a quick preview for common Java-style pattern inputs, not JVM execution.
The engines support different syntax and matching rules, and the page only preprocesses a limited subset of Java-style options. Check the pattern with the JDK version your program uses before relying on it.
Enter the regex pattern text itself. If copying from Java code, remove the extra escaping required by the Java string literal when appropriate; for example, a Java literal containing \d+ represents a regex pattern containing \d+.
Multiline changes how start and end anchors work around lines. Dotall changes whether a dot can match a newline. They address separate pattern behaviors.
Notes
Review scope, result limitations, and important precautions before use.
Pattern and Matcher calls.Related
Discover related tools, collections, and available API capabilities.