int beginOffset = 0;
MatchResult currentResult;
PatternMatcherInput pinput = new PatternMatcherInput(rawTemplate);
while(matcher.contains(pinput, templatePattern)) {
currentResult = matcher.getMatch();
final int beginMatch = currentResult.beginOffset(0);
if (beginMatch > beginOffset) { // string is not empty
combined.add(rawTemplate.substring(beginOffset, beginMatch));
}
combined.add(Integer.valueOf(currentResult.group(1)));// add match as Integer
beginOffset = currentResult.endOffset(0);