Can someone help me to understand why using \\d* returns an array containing an empty string, whereas using \\d+ returns [\"100\"] (as expected). I get why the \\d+ works, b
* means 0 or more, so it's matching 0 times. You need to use + for 1 or more. By default it's greedy, so will match 100:
*
+
100
var str = 'one to 100'; var regex = /\d+/; console.log(str.match(regex)); // ["100"]