From ddefeb630a632f181b96a243fd7cb299c3bb3b5b Mon Sep 17 00:00:00 2001 From: gaoxiongzaq Date: Fri, 15 Mar 2024 11:17:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=8E=9F=E6=9D=A5=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/keking/utils/RarUtils.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/cn/keking/utils/RarUtils.java b/server/src/main/java/cn/keking/utils/RarUtils.java index 1a863fe8..a08c1ce6 100644 --- a/server/src/main/java/cn/keking/utils/RarUtils.java +++ b/server/src/main/java/cn/keking/utils/RarUtils.java @@ -75,20 +75,15 @@ public class RarUtils { public static boolean judge(char c){ return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); } - public static String specialSymbols(String str) { - //去除压缩包文件字符串中特殊符号 - // Pattern p = Pattern.compile("\\s|\\+|#|&|=|\\p{P}"); - String regEx="[`+=~&']"; - Pattern p = Pattern.compile(regEx); - Matcher m = p.matcher(str); - return m.replaceAll(""); - } - public static boolean isMessyCode(String strName) { //去除字符串中的空格 制表符 换行 回车 - strName = specialSymbols(strName).replaceAll("\\p{P}", ""); + Pattern p = Pattern.compile("\\s*|\t*|\r*|\n*"); + Matcher m = p.matcher(strName); + String after = m.replaceAll("").replaceAll("\\+", "").replaceAll("#", "").replaceAll("&", ""); + //去除字符串中的标点符号 + String temp = after.replaceAll("\\p{P}", ""); //处理之后转换成字符数组 - char[] ch = strName.trim().toCharArray(); + char[] ch = temp.trim().toCharArray(); for (char c : ch) { //判断是否是数字或者英文字符 if (!judge(c)) {