I have input string to process of the format
xxx:xxx:xxx:xxx:filters:6:item:xxx
Where xxx
could by any combination of alphanumerics and underscore.
I am trying to capture the number between filters
and item
using regular expressions.
I have the regular expression \\S*filters:(\\d+):item\\S*
and it matches OK but I cannot work out how to extract the number.
The test code
Pattern myPattern = Pattern.compile('\\S*filters:(\\d+):item\\S*');
Matcher myMatcher = myPattern.matcher('aaaaab:filters:3:item:foo');
system.debug(myMatcher.matches());
system.debug(myMatcher.groupCount());
system.debug(myMatcher.group(0));
outputs the following:
true
1
aaaaab:filters:3:item:foo
as you see, the group has captured who whole string, not just the number which I want.
How do I get the number?