How can I define repetitive groups in Java Regex?
Lets say a 2digit number [0-9]{2} multiple times separates by ,
12,34,98,11
Is that p
That's supported in Java Regex. See Pattern documentation. Here's an example:
"11,12,13".matches("\\d{2}(,\\d{2})*"); // true
You can then split the string with String.split(), a Scanner or a StringTokenizer. Examples:
String[] split = "11,12,13".split(",");
StringTokenizer stringTokenizer = new StringTokenizer("11,12,13", ",");
Scanner scanner = new Scanner("11,12,13").useDelimiter(",");
while (scanner.hasNext()) {
// scanner.next()
}