mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
Revert to numbered capturing groups in CardEdition regexes
This commit is contained in:
@@ -608,17 +608,30 @@ public final class CardEdition implements Comparable<CardEdition> {
|
|||||||
it should also match the Un-set and older alternate art cards
|
it should also match the Un-set and older alternate art cards
|
||||||
like Merseine from FEM.
|
like Merseine from FEM.
|
||||||
*/
|
*/
|
||||||
|
/* Ideally we'd use the named group above, but Android *25* and
|
||||||
|
earlier doesn't appear to support named groups.
|
||||||
|
So, untill support for those devices is officially dropped,
|
||||||
|
we'll have to suffice with numbered groups.
|
||||||
|
We are looking for:
|
||||||
|
* cnum - grouping #1
|
||||||
|
* rarity - grouping #2
|
||||||
|
* name - grouping #3
|
||||||
|
* artist name - grouping #4
|
||||||
|
* extra parameters - grouping #5
|
||||||
|
*/
|
||||||
// Collector numbers now should allow hyphens for Planeswalker Championship Promos
|
// Collector numbers now should allow hyphens for Planeswalker Championship Promos
|
||||||
"(?:^(?<cnum>.?[0-9A-Z-]+\\S*[A-Z]*)\\s)?(?:(?<rarity>[SCURML])\\s)?(?<name>[^@$]*)(?: @(?<artist>[^$]*))?(?: \\$\\{(?<params>.+)})?$"
|
"(?:^(.?[0-9A-Z-]+\\S*[A-Z]*)\\s)?(?:([SCURML])\\s)?(?<name>[^@$]*)(?: @([^$]*))?(?: \\$\\{(.+)})?$"
|
||||||
|
//"(?:^(?<cnum>.?[0-9A-Z-]+\\S*[A-Z]*)\\s)?(?:(?<rarity>[SCURML])\\s)?(?<name>[^@$]*)(?: @(?<artist>[^$]*))?(?: \\$\\{(?<params>.+)})?$"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final Pattern TOKEN_PATTERN = Pattern.compile(
|
public static final Pattern TOKEN_PATTERN = Pattern.compile(
|
||||||
/*
|
/*
|
||||||
* cnum - grouping #2
|
* cnum - grouping #1
|
||||||
* name - grouping #3
|
* name - grouping #2
|
||||||
* artist name - grouping #5
|
* artist name - grouping #3
|
||||||
*/
|
*/
|
||||||
"(?:^(?<cnum>.?[0-9A-Z-]+\\S?[A-Z☇]*)\\s)?(?<name>[^@]*)(?: @(?<artist>.*))?$"
|
//"(?:^(?<cnum>.?[0-9A-Z-]+\\S?[A-Z☇]*)\\s)?(?<name>[^@]*)(?: @(?<artist>.*))?$"
|
||||||
|
"(?:^(.?[0-9A-Z-]+\\S?[A-Z☇]*)\\s)?([^@]*)(?: @(.*))?$"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final Pattern EXTRA_PARAMS_PATTERN = Pattern.compile(
|
public static final Pattern EXTRA_PARAMS_PATTERN = Pattern.compile(
|
||||||
@@ -679,11 +692,11 @@ public final class CardEdition implements Comparable<CardEdition> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String collectorNumber = matcher.group("cnum");
|
String collectorNumber = matcher.group(1);
|
||||||
CardRarity r = CardRarity.smartValueOf(matcher.group("rarity"));
|
CardRarity r = CardRarity.smartValueOf(matcher.group(2));
|
||||||
String cardName = matcher.group("name");
|
String cardName = matcher.group(3);
|
||||||
String artistName = matcher.group("artist");
|
String artistName = matcher.group(4);
|
||||||
String extraParamText = matcher.group("params");
|
String extraParamText = matcher.group(5);
|
||||||
Map<String, String> extraParams = null;
|
Map<String, String> extraParams = null;
|
||||||
if(!StringUtils.isBlank(extraParamText)) {
|
if(!StringUtils.isBlank(extraParamText)) {
|
||||||
Matcher paramMatcher = EXTRA_PARAMS_PATTERN.matcher(extraParamText);
|
Matcher paramMatcher = EXTRA_PARAMS_PATTERN.matcher(extraParamText);
|
||||||
@@ -729,9 +742,9 @@ public final class CardEdition implements Comparable<CardEdition> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String collectorNumber = matcher.group("cnum");
|
String collectorNumber = matcher.group(1);
|
||||||
String cardName = matcher.group("name");
|
String cardName = matcher.group(2);
|
||||||
String artistName = matcher.group("artist");
|
String artistName = matcher.group(3);
|
||||||
// rarity isn't used for this anyway
|
// rarity isn't used for this anyway
|
||||||
EditionEntry tis = new EditionEntry(cardName, collectorNumber, CardRarity.Token, artistName, null);
|
EditionEntry tis = new EditionEntry(cardName, collectorNumber, CardRarity.Token, artistName, null);
|
||||||
tokenMap.put(cardName, tis);
|
tokenMap.put(cardName, tis);
|
||||||
@@ -746,9 +759,9 @@ public final class CardEdition implements Comparable<CardEdition> {
|
|||||||
if (!matcher.matches()) {
|
if (!matcher.matches()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String collectorNumber = matcher.group("cnum");
|
String collectorNumber = matcher.group(1);
|
||||||
String cardName = matcher.group("name");
|
String cardName = matcher.group(2);
|
||||||
String artistName = matcher.group("artist");
|
String artistName = matcher.group(3);
|
||||||
EditionEntry tis = new EditionEntry(cardName, collectorNumber, CardRarity.Unknown, artistName, null);
|
EditionEntry tis = new EditionEntry(cardName, collectorNumber, CardRarity.Unknown, artistName, null);
|
||||||
otherMap.put(cardName, tis);
|
otherMap.put(cardName, tis);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user