diff --git a/src/main/java/com/lion/lionwebsite/Service/LocalServiceImpl.java b/src/main/java/com/lion/lionwebsite/Service/LocalServiceImpl.java index a661535..9e601c8 100644 --- a/src/main/java/com/lion/lionwebsite/Service/LocalServiceImpl.java +++ b/src/main/java/com/lion/lionwebsite/Service/LocalServiceImpl.java @@ -23,6 +23,8 @@ import java.nio.file.attribute.BasicFileAttributes; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static java.nio.file.FileVisitResult.CONTINUE; @@ -93,13 +95,23 @@ public class LocalServiceImpl{ String DouNaiV2rayRaw = Get(DouNaiV2ray).getFirst(); String[] v2rayPlain = new String(Base64.getDecoder().decode(DouNaiV2rayRaw)).split("\n"); StringBuilder stringBuilder = new StringBuilder(); + Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?"); + //过滤高倍率节点 for(String node: v2rayPlain){ String name = URLDecoder.decode(node.split("#")[1], StandardCharsets.UTF_8); - if(name.startsWith("⛅") && name.contains("流量")){ - float ratio = Float.parseFloat(name.substring(name.indexOf("(") + 1, name.indexOf(")")).replace("倍流量", "")); - if(ratio <= 1) - stringBuilder.append(node).append("\n"); + if(name.contains("流量")){ + Matcher matcher = pattern.matcher(name.substring(name.indexOf("(") + 1, name.indexOf(")"))); + + if (matcher.find()) { + // 将匹配到的数字添加到列表中 + float ratio = Float.parseFloat(matcher.group()); + if(ratio <= 1) { + stringBuilder.append(node).append("\n"); + continue; + } + } + stringBuilder.append(node).append("\n"); } else{ stringBuilder.append(node).append("\n");