play1
play1 copied to clipboard
[#1764]feature: add advanced urlcheck
replacement for #706
@asolntsev is that version better? https://gist.github.com/flybyray/4c8c974d104478a101713ec9f9171038
@flybyray I added a comment to the gist:
May be this could be a shorter solution:
private static String[] origRegex = { ... };
private static String[][] regexFragments = {
origRegex,
replace(origRegex, 4, "(?!(?:10)(?:\\.\\d{1,3}){3})"),
replace(origRegex, 13, ""),
replace(origRegex, 13, "")
};
P.S. I agree, all my comments are quite minor (cosmetic).
would need something like this. but is this nicer to read?
private static String[] origRegex = { ... };
private static IntFunction[] intf = {
x -> (x == 4) ? "(?!(?:10)(?:\\.\\d{1,3}){3})" : null,
x -> (x == 13) ? "" : null
};
private static String[][] regexFragments = {
origRegex,
replace(origRegex.clone(), intf[0]),
replace(origRegex.clone(), intf[1]),
replace(replace(origRegex.clone(), intf[0]), intf[1])};
private static String[] replace(String[] array, IntFunction<? extends String> generator) {
for (int i = 0; i < array.length; i++) {
final String object = generator.apply(i);
if (object != null) array[i] = object;
}
return array;
}