import static com.google.common.collect.Lists.newArrayList;
import static java.util.Arrays.asList;
+import static java.util.regex.Pattern.CASE_INSENSITIVE;
+import static java.util.regex.Pattern.UNICODE_CASE;
+import static java.util.regex.Pattern.compile;
import java.io.IOException;
import java.io.Writer;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.regex.Pattern;
import net.pterodactylus.xdcc.core.Core;
import net.pterodactylus.xdcc.data.Bot;
private static class SearchParameter {
private final boolean exclude;
- private final String pattern;
+ private final Pattern pattern;
- private SearchParameter(boolean exclude, String pattern) {
+ private SearchParameter(boolean exclude, Pattern pattern) {
this.exclude = exclude;
this.pattern = pattern;
}
public boolean matches(String filename) {
- boolean matches = filename.toLowerCase().contains(pattern.toLowerCase());
- return matches && !exclude;
+ return pattern.matcher(filename).find() && !exclude;
}
public static SearchParameter from(String parameter) {
boolean exclude = parameter.startsWith("-");
- String pattern = exclude ? parameter.substring(1) : parameter;
+ Pattern pattern = compile(exclude ? parameter.substring(1) : parameter, CASE_INSENSITIVE | UNICODE_CASE);
return new SearchParameter(exclude, pattern);
}