The string hhh contains two hs, therefore the regex matches since the find() method allows matching of substrings.

If you anchor the regex to force it to match the entire string, the regex will fail:

^h{2}$

Another possibility would be to use the matches() method:

"hhh".matches("h{2}")

will fail.

Answer from Tim Pietzcker on Stack Overflow
🌐
Regexplanet
regexplanet.com β€Ί advanced β€Ί java β€Ί index.html
Java regex testing - RegexPlanet
Online testing for Java (java.util.regex.Pattern) regular expressions.
🌐
FreeFormatter
freeformatter.com β€Ί java-regex-tester.html
Free Online Java Regular Expression Tester - FreeFormatter.com
Free online Java regular expression tester with cheatsheet and most common solutions to common problems
People also ask

Does this tool use the Java regex engine?
This tool runs in the browser using the JavaScript regex engine, which is similar to Java but has some differences. Possessive quantifiers (*+, ++), atomic groups (?>...), and some Unicode properties (\p{IsGreek}) work in Java but not in JavaScript. Always verify critical patterns in a Java runtime.
🌐
qodex.ai
qodex.ai β€Ί all-tools β€Ί java-regex-tester
Java Regex Tester, Test Patterns Live Online
How do I write a regex pattern in Java code?
Use Pattern.compile() and Matcher from java.util.regex to define and apply regex.
🌐
qodex.ai
qodex.ai β€Ί all-tools β€Ί java-regex-tester
Java Regex Tester, Test Patterns Live Online
How can I make my regex case-insensitive in Java?
Use the (?i) flag in the pattern or Pattern.CASE_INSENSITIVE.
🌐
qodex.ai
qodex.ai β€Ί all-tools β€Ί java-regex-tester
Java Regex Tester, Test Patterns Live Online
🌐
Regex101
regex101.com
regex101: build, test, and debug regex
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.
🌐
Qodex
qodex.ai β€Ί all-tools β€Ί java-regex-tester
Java Regex Tester, Test Patterns Live Online
Test and debug Java regex patterns in real time. See matches highlighted, capture groups extracted, and flags applied instantly. Free, no signup.
🌐
Regex101
regex101.com β€Ί r β€Ί hj0miD β€Ί 1
regex101: Java Regex
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.
🌐
JetBrains
plugins.jetbrains.com β€Ί plugin β€Ί 2917-regexp-tester
Regexp Tester Plugin for JetBrains IDEs | JetBrains Marketplace
December 20, 2025 - Regular Expression tester. Helps to experiment with Java regular expressions. Highlights matched text, shows detailed information about matched groups. Can highlight the problematic part of an unmatched regex.
Rating: 4.3 ​ - ​ 28 votes
🌐
Regextester
regextester.github.io
RegEx Tester
Regular Expression Tester for .Net, Python, Java and JavaScript
Find elsewhere
🌐
Regex-testdrive
regex-testdrive.com β€Ί en
Regex Online Tester | Regular Expression Test Drive
This site allows you to check the operation of the regular expression for Java. Regular expression string specified by the TEST button is tested, I can confirm the result
🌐
GitHub
github.com β€Ί janissl β€Ί simple-java-regex-tester
GitHub - janissl/simple-java-regex-tester: A GUI application for simple testing of Java regular expressions if they have any matches. Β· GitHub
A tool for testing Java regular expressions. Matches are higlighted in green at the top pane. Match positions as well as matched regex groups are displayed in the bottom pane.
Author Β  janissl
🌐
GitHub
github.com β€Ί nickawatts β€Ί regex-tester
GitHub - nickawatts/regex-tester: Java library that helps you test regular expressions with JUnit. Β· GitHub
If you need support for earlier Java or JUnit versions, please submit an issue report explaining your needs. regex-tester provides a simple API for testing regular expressions in Java.
Starred by 8 users
Forked by 2 users
Languages Β  Java
🌐
Javainuse
javainuse.com β€Ί regtester
Online Regex Tester and Debugger Tool
Hex Encoder/Decoder Convert text ... documents to YAML YAML -> JSON Transform YAML into JSON YAML -> POJO Generate Java models from YAML Regex Generator Compose regex patterns visually Regex Tester Debug expressions against sample text XML -> POJO Convert XML into Java classes ...
🌐
JetBrains
plugins.jetbrains.com β€Ί plugin β€Ί 11370-dukescript-java-regex-tester
Dukescript Java Regex Tester - IntelliJ IDEs Plugin | Marketplace
An easy to use regular expressions tool (builder, tester, valid values generator) It has the following characteristics: Pasting of unescaped regular expression Auto...
🌐
Myregexp
myregexp.com
Regular Expression Tester
To test JAVA regular expression you can use java-applet
🌐
Regexplanet
regexplanet.com
RegexPlanet
Regular expression (regex/regexp) testing and debugging for Your Browser, Bun, Deno, Go, Java, .NET, Node.js, Perl, PHP, PostgreSQL, Python, Ruby, Rust, Swift, tcl, XRegExp.
🌐
Medium
medium.com β€Ί @rahul.javatpoint12 β€Ί java-regex-testing-what-you-need-to-know-00778eaee574
Java Regex Testing: What You Need to Know | by Rahul | Medium
November 20, 2024 - Use Online Tools: Utilize online regex testers like regex101.com to quickly test and debug your patterns. Document Your Patterns: Comment your regex patterns to explain their purpose and structure, making them easier to understand and maintain.
🌐
GitHub
github.com β€Ί DinoChiesa β€Ί Regex-Java-Test
GitHub - DinoChiesa/Regex-Java-Test Β· GitHub
This repo is a simple developer's aid in building and testing regex, implemented in Java. You would use this if you want to build your own regular expressions, and test them rigorously against a large-ish data set of sample data.
Author Β  DinoChiesa
🌐
TestRegex
testregex.com β€Ί home β€Ί java regex tester & debugger
Online Java Regex Tester - java.util.regex - TestRegex
Test Java regex patterns against java.util.regex.Pattern rules. Supports unicode character classes and canon_eq scaling.
🌐
RegExr
regexr.com
RegExr: Learn, Build, & Test RegEx
RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).
🌐
W3Schools
w3schools.com β€Ί java β€Ί java_regex.asp
Java Regular Expressions
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Pattern pattern = Pattern.compile("w3schools", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher("Visit W3Schools!"); boolean matchFound = matcher.find(); if(matchFound) { System.out.println("Match found"); } else { System.out.println("Match not found"); } } } // Outputs Match found