提交 2d12d36f authored 作者: wyl's avatar wyl

极简版规则

上级 910c0a3f
......@@ -23,6 +23,7 @@ import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
@Component
public class Adaptor {
......@@ -97,7 +98,8 @@ public class Adaptor {
for(MatchAndRule regular:strings1) {
//if (FileSystems.getDefault().getPathMatcher("glob:"+regular.getMath()).matches(file)) {
//直接用java正则
if (FileSystems.getDefault().getPathMatcher(regular.getMath()).matches(file)) {
String s = regular.getMath().replaceAll("\\?", ".").replaceAll("\\*", ".+");
if (Pattern.matches(s,file.getFileName().toString())) {
if(thisFileMatched==null)thisFileMatched = new ArrayList<>();
thisFileMatched.add(regular.getRule());
match = true;
......@@ -189,6 +191,7 @@ public class Adaptor {
List<MatchAndRule> result = new ArrayList<>();
for (Rule adaptorEntity : ruleList) {
System.out.println(adaptorEntity.getPath());
adaptorEntity.setPath(adaptorEntity.getPath().replaceAll("\\?",".").replaceAll("\\*",".+"));
// System.out.println(adaptorEntity.getTarget()+"11");
// System.out.println(adaptorEntity.getPathMatchType());
// System.out.println(adaptorEntity);
......
......@@ -9,6 +9,7 @@ import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class Test1 {
@Test
......@@ -684,4 +685,9 @@ public class Test1 {
System.out.println(sb.toString());
}
@Test
public void test5(){
System.out.println(Pattern.matches(".+22.+","2223"));
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论