diff --git a/timestring.js b/timestring.js index 623a927..a8cca74 100644 --- a/timestring.js +++ b/timestring.js @@ -78,13 +78,13 @@ // split string into groups and get total seconds for each group var groups = string .replace(/[^\w+-]+/g, '') // remove white space - .match(/[-+]?[0-9]*\.?[0-9]+\D/g); // match time groups (digit followed by time unit - i.e 5d 15m = 2 time groups) + .match(/[-+]?[0-9]+[a-z]+/g); // match time groups (digit followed by time unit - i.e 5d 15m = 2 time groups) if (groups !== null) { for(var group in groups) { var g = groups[group], - value = g.match(/[-+]?[0-9]*\.?[0-9]+/g), - unit = g.match(new RegExp(unitsRegExp, 'g')); + value = g.match(/[0-9]+/g), + unit = g.match(/[a-z]+/g); totalSeconds += getSeconds(value, unit); }