fixed regex, put back code block where it was

This commit is contained in:
gorhill 2014-04-23 19:13:48 -04:00
parent 815886d9f2
commit a557574d6c
1 changed files with 12 additions and 12 deletions

View File

@ -179,7 +179,7 @@ var (
/******************************************************************************/ /******************************************************************************/
var ( var (
layoutWildcard = `^\*|\?$` layoutWildcard = `^\*$|^\?$`
layoutValue = `^(%value%)$` layoutValue = `^(%value%)$`
layoutRange = `^(%value%)-(%value%)$` layoutRange = `^(%value%)-(%value%)$`
layoutWildcardAndInterval = `^\*/(\d+)$` layoutWildcardAndInterval = `^\*/(\d+)$`
@ -412,16 +412,6 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error)
} }
snormal := strings.ToLower(s[indices[i][0]:indices[i][1]]) 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) { if makeLayoutRegexp(layoutWildcard, desc.valuePattern).MatchString(snormal) {
directive.kind = all directive.kind = all
@ -439,7 +429,7 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error)
continue continue
} }
// `5-20` // `5-20`
pairs = makeLayoutRegexp(layoutRange, desc.valuePattern).FindStringSubmatchIndex(snormal) pairs := makeLayoutRegexp(layoutRange, desc.valuePattern).FindStringSubmatchIndex(snormal)
if len(pairs) > 0 { if len(pairs) > 0 {
directive.kind = span directive.kind = span
directive.first = desc.atoi(snormal[pairs[2]:pairs[3]]) 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) directives = append(directives, &directive)
continue 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` // `5/2`
pairs = makeLayoutRegexp(layoutValueAndInterval, desc.valuePattern).FindStringSubmatchIndex(snormal) pairs = makeLayoutRegexp(layoutValueAndInterval, desc.valuePattern).FindStringSubmatchIndex(snormal)
if len(pairs) > 0 { if len(pairs) > 0 {