I\'m making a text based dice roller. It takes in strings like \"2d10+5\" and returns a string as a result of the roll(s). My problem is showing up in the tokenizer that spl
I'd recommend simple matching rather than splitting:
Matcher matcher = Pattern.compile("([1-9]*)(d[0-9%]+)([+-][0-9]+)?").matcher(string); if(matcher.matches()) { String first = matcher.group(1); // etc }
No guarantee for the regex, but I think it will do...