views:

129

answers:

0

given text:1,0397,030 followed by nothing or any number of characters not in the set [,0-9] why is my regex not being greedy enough? Javascript's regex is supposed to be greedy by default, right?

but text.match('[,0-9]+'); pulls back 1,0397 instead of 1,0397,030

var matches = shortInput.match('[0-9]+[,0-9]*[0-9]*');

works. This is in chrome 4.1.249.1059 (44723)

so perhaps it's a chrome issue?

why isn't it greedy enough?