Answers for "java string matches regex number"

1

number regex java

String regex = "[0-9]+"; // or String regex = "\\d+";
String str = "123";
System.out.println(str.matches(regex)); // true
str = "12a";
System.out.println(str.matches(regex)); // false
Posted by: Guest on March-02-2022
0

number of matches regex java

// Java 9+
long matches = matcher.results().count();

// Java 8-
int count = 0;
while (matcher.find())
{
	count++;
}
Posted by: Guest on June-16-2020

Code answers related to "java string matches regex number"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language