Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Javaで正規表現に一致するすべての部分文字列を見つけるにはどうすればよいですか? ( .Net のRegex.Matchesに似ています)
マッチャーを作成し、それを使用find()して次のマッチに配置します。
find()
コードサンプルは次のとおりです。
int countMatches(Pattern pattern, String str) { int matches = 0; Matcher matcher = pattern.matcher(str); while (matcher.find()) matches++; return matches; }