javascript - string.search | number of hits -


i'm searching number in string, using .search string method:

var mystring = "20 fur bar 50"; alert(mystring.search(/\d/); 

this returns position of first number: 0. how can position of second number? there way find out how many hits there are?

use match instead , g (global) flag.

jsfiddle.

if don't want match digits individually, change \d+.

jsfiddle.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -