java string matches

Viewed 44

I don't understand why this match returns true

String text = "2";
boolean result= text.matches("[12]?[\\d]{1,2}");

what about the [\\d]{1,2} in the expression??

For me the text which returns true should be with 2 o 3 digits like 17 or 289.

Thanks

0 Answers
Related