mirror of
https://github.com/frode-carlsen/cron.git
synced 2025-12-06 05:50:54 +03:00
Problem: the regex does not get parsed on Android 4;
Solution: move from named groups to indexed ones
This commit is contained in:
@@ -276,14 +276,14 @@ public class CronExpression {
|
|||||||
abstract static class BasicField {
|
abstract static class BasicField {
|
||||||
private static final Pattern CRON_FELT_REGEXP = Pattern
|
private static final Pattern CRON_FELT_REGEXP = Pattern
|
||||||
.compile("(?: # start of group 1\n"
|
.compile("(?: # start of group 1\n"
|
||||||
+ " (?:(?<all>\\*)|(?<ignorer>\\?)|(?<last>L)) # globalt flag (L, ?, *)\n"
|
+ " (?:(\\*)|(\\?)|(L)) # globalt flag (L, ?, *)\n"
|
||||||
+ " | (?<start>[0-9]{1,2}|[a-z]{3,3}) # or start number or symbol\n"
|
+ " | ([0-9]{1,2}|[a-z]{3,3}) # or start number or symbol\n"
|
||||||
+ " (?: # start of group 2\n"
|
+ " (?: # start of group 2\n"
|
||||||
+ " (?<mod>L|W) # modifier (L,W)\n"
|
+ " (L|W) # modifier (L,W)\n"
|
||||||
+ " | -(?<end>[0-9]{1,2}|[a-z]{3,3}) # or end nummer or symbol (in range)\n"
|
+ " | -([0-9]{1,2}|[a-z]{3,3}) # or end nummer or symbol (in range)\n"
|
||||||
+ " )? # end of group 2\n"
|
+ " )? # end of group 2\n"
|
||||||
+ ") # end of group 1\n"
|
+ ") # end of group 1\n"
|
||||||
+ "(?:(?<inkmod>/|\\#)(?<ink>[0-9]{1,7}))? # increment and increment modifier (/ or \\#)\n"
|
+ "(?:(/|\\#)([0-9]{1,7}))? # increment and increment modifier (/ or \\#)\n"
|
||||||
, Pattern.CASE_INSENSITIVE | Pattern.COMMENTS);
|
, Pattern.CASE_INSENSITIVE | Pattern.COMMENTS);
|
||||||
|
|
||||||
final CronFieldType fieldType;
|
final CronFieldType fieldType;
|
||||||
@@ -301,11 +301,11 @@ public class CronExpression {
|
|||||||
if (!m.matches()) {
|
if (!m.matches()) {
|
||||||
throw new IllegalArgumentException("Invalid cron field '" + rangePart + "' for field [" + fieldType + "]");
|
throw new IllegalArgumentException("Invalid cron field '" + rangePart + "' for field [" + fieldType + "]");
|
||||||
}
|
}
|
||||||
String startNummer = m.group("start");
|
String startNummer = m.group(4);
|
||||||
String modifier = m.group("mod");
|
String modifier = m.group(5);
|
||||||
String sluttNummer = m.group("end");
|
String sluttNummer = m.group(6);
|
||||||
String inkrementModifier = m.group("inkmod");
|
String inkrementModifier = m.group(7);
|
||||||
String inkrement = m.group("ink");
|
String inkrement = m.group(8);
|
||||||
|
|
||||||
FieldPart part = new FieldPart();
|
FieldPart part = new FieldPart();
|
||||||
part.increment = 999;
|
part.increment = 999;
|
||||||
@@ -320,14 +320,14 @@ public class CronExpression {
|
|||||||
} else {
|
} else {
|
||||||
part.to = part.from;
|
part.to = part.from;
|
||||||
}
|
}
|
||||||
} else if (m.group("all") != null) {
|
} else if (m.group(1) != null) {
|
||||||
part.from = fieldType.from;
|
part.from = fieldType.from;
|
||||||
part.to = fieldType.to;
|
part.to = fieldType.to;
|
||||||
part.increment = 1;
|
part.increment = 1;
|
||||||
} else if (m.group("ignorer") != null) {
|
} else if (m.group(2) != null) {
|
||||||
part.modifier = m.group("ignorer");
|
part.modifier = m.group(2);
|
||||||
} else if (m.group("last") != null) {
|
} else if (m.group(3) != null) {
|
||||||
part.modifier = m.group("last");
|
part.modifier = m.group(3);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid cron part: " + rangePart);
|
throw new IllegalArgumentException("Invalid cron part: " + rangePart);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user