java - counting instances of int in a string -


trying count how many integers within string

system.out.println("enter numbers, eg 1 2 3: "); = scan.nextline(); b = count(a).length; 

this not work. there simple method this?

try this

    matcher m = pattern.compile("\\d++").matcher(input);     int n = 0;     while(m.find()) {         n++;     } 

Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c++ - CryptStringToBinary API behavior -