From a557574d6c024ed6e36acc8b610f5f211c91568a Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 23 Apr 2014 19:13:48 -0400 Subject: [PATCH] fixed regex, put back code block where it was --- cronexpr_parse.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cronexpr_parse.go b/cronexpr_parse.go index a1ab438..289ad53 100644 --- a/cronexpr_parse.go +++ b/cronexpr_parse.go @@ -179,7 +179,7 @@ var ( /******************************************************************************/ var ( - layoutWildcard = `^\*|\?$` + layoutWildcard = `^\*$|^\?$` layoutValue = `^(%value%)$` layoutRange = `^(%value%)-(%value%)$` layoutWildcardAndInterval = `^\*/(\d+)$` @@ -412,16 +412,6 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error) } snormal := strings.ToLower(s[indices[i][0]:indices[i][1]]) - // `*/2` - pairs := makeLayoutRegexp(layoutWildcardAndInterval, desc.valuePattern).FindStringSubmatchIndex(snormal) - if len(pairs) > 0 { - directive.kind = span - directive.first = desc.min - directive.last = desc.max - directive.step = atoi(snormal[pairs[2]:pairs[3]]) - directives = append(directives, &directive) - continue - } // `*` if makeLayoutRegexp(layoutWildcard, desc.valuePattern).MatchString(snormal) { directive.kind = all @@ -439,7 +429,7 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error) continue } // `5-20` - pairs = makeLayoutRegexp(layoutRange, desc.valuePattern).FindStringSubmatchIndex(snormal) + pairs := makeLayoutRegexp(layoutRange, desc.valuePattern).FindStringSubmatchIndex(snormal) if len(pairs) > 0 { directive.kind = span directive.first = desc.atoi(snormal[pairs[2]:pairs[3]]) @@ -448,6 +438,16 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error) directives = append(directives, &directive) continue } + // `*/2` + pairs = makeLayoutRegexp(layoutWildcardAndInterval, desc.valuePattern).FindStringSubmatchIndex(snormal) + if len(pairs) > 0 { + directive.kind = span + directive.first = desc.min + directive.last = desc.max + directive.step = atoi(snormal[pairs[2]:pairs[3]]) + directives = append(directives, &directive) + continue + } // `5/2` pairs = makeLayoutRegexp(layoutValueAndInterval, desc.valuePattern).FindStringSubmatchIndex(snormal) if len(pairs) > 0 {