[0-6, 1-3][01-20, 22-23]22/123
From the above input, I would like to extract the following the following texts.
0-6, 1-3
01-20, 22-23
22
123
The following code snippets extracts the required texts excepts the first one.
Pattern depArrHours = Pattern.compile("^(\\[(.+)\\]){2}(.+)\\/(.+)$");
Matcher matcher = depArrHours.matcher("[0-6, 1-3][01-20, 22-23]22/123");
if (matcher.matches()) {
System.out.println(matcher.group(0));
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
System.out.println(matcher.group(3));
System.out.println(matcher.group(4));
}
Output:
[0-6, 1-3][01-20, 22-23]22/123
[01-20, 22-23]
01-20, 22-23
22
123
Can you please help me to fix my regex pattern to extract the first part also(0-6, 1-3)?