Name: Anonymous 2009-02-24 16:11
Trying to create a dicerolling application that, among other input, accepts a 'roll expression' from a textfield(eg. 4D20+1). Regex then matches this up, and if correct, breaks the statement down, 'rolls' and returns a result. For the moment I'm jsut looking for true/false for match.
I'm having trouble getting regex to match though.
Can any of you fine chaps help?
String r = "\\d+d\\d+\\+\\d+";
try{
pattern = Pattern.compile(r);
}
catch(Exception e){
return(e.getMessage());
}
matcher = pattern.matcher(r);
Boolean match = (matcher.matches());
return(match.toString());
This always report false.
I know my regex statement is the problem, what with the '+' character(probably not the only source of fail...?)
Any help gents?
I'm having trouble getting regex to match though.
Can any of you fine chaps help?
String r = "\\d+d\\d+\\+\\d+";
try{
pattern = Pattern.compile(r);
}
catch(Exception e){
return(e.getMessage());
}
matcher = pattern.matcher(r);
Boolean match = (matcher.matches());
return(match.toString());
This always report false.
I know my regex statement is the problem, what with the '+' character(probably not the only source of fail...?)
Any help gents?