Simple java regex not matching -
my regex returning false, cant understand why.
pattern patt = pattern.compile("\\d+"); patt.matcher("a 18c1").matches(); //returning false also tried [0-9]+ , (\\d+), ([0-9]+), didnt work too.. can me? thanks
this because use .matches(). want .find().
.matches() misnomer; try , match against entire input. regex matching done using .find():
final matcher matcher = patt.matcher("a 18c1"); if (matcher.find()) system.out.println(matcher.group());
Comments
Post a Comment