fix regular expressions

This commit is contained in:
Mike Barrett 2012-12-30 23:27:17 +00:00
parent 713022f729
commit fc1941e2bc

View File

@ -78,13 +78,13 @@
// split string into groups and get total seconds for each group // split string into groups and get total seconds for each group
var groups = string var groups = string
.replace(/[^\w+-]+/g, '') // remove white space .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) { if (groups !== null) {
for(var group in groups) { for(var group in groups) {
var g = groups[group], var g = groups[group],
value = g.match(/[-+]?[0-9]*\.?[0-9]+/g), value = g.match(/[0-9]+/g),
unit = g.match(new RegExp(unitsRegExp, 'g')); unit = g.match(/[a-z]+/g);
totalSeconds += getSeconds(value, unit); totalSeconds += getSeconds(value, unit);
} }