Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
fixed regex, put back code block where it was
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Apr 23, 2014
1 parent 815886d commit a557574
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions cronexpr_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var (
/******************************************************************************/

var (
layoutWildcard = `^\*|\?$`
layoutWildcard = `^\*$|^\?$`
layoutValue = `^(%value%)$`
layoutRange = `^(%value%)-(%value%)$`
layoutWildcardAndInterval = `^\*/(\d+)$`
Expand Down Expand Up @@ -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
Expand 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]])
Expand All @@ -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 {
Expand Down

0 comments on commit a557574

Please sign in to comment.