From fc1941e2bcb84ade678b642f748bbea52f448a56 Mon Sep 17 00:00:00 2001 From: Mike Barrett Date: Sun, 30 Dec 2012 23:27:17 +0000 Subject: [PATCH] fix regular expressions --- timestring.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); }