var str = " 111 222 333", re = /\d+/g, i = 0, ar = [] , res; while ( (res = re.exec(str)) != null) { ar[i] = res[0]; alert(ar[i]); i++; }