Maybe I have missed something, but what are wrong with this regular expresion?
var str = "lorem ipsum 12345 dolor";
var x = /\d+/.exec(str);
var y = /\d*/.exec(str);
console.log(x); // will print 12345
console.log(y); // will print "" but why ?
Can you please explain why /\d*/.exec(str);
returns an empty string instead of "12345". *
means zero or more number of matches.