regex count in single match

Posted by 01 on Stack Overflow See other posts from Stack Overflow or by 01
Published on 2010-03-26T10:06:04Z Indexed on 2010/03/26 10:13 UTC
Read the original article Hit count: 412

Filed under:
|
|
|

i want to check if string doesnt have more than 5 numbers, i can do it this way


Matcher matcher = Pattern.compile("\\d").matcher(val);
        i = 0;
        while (matcher.find()) {
            i++;
        }

However i would like to do it without while(because we are using regex validation framework). I want to be able to match strings like

A2sad..3f,3,sdasad2..2

© Stack Overflow or respective owner

Related posts about regex

Related posts about count