From 1eee8ead1cbd2325b7b6d2ce29b0b8da099624de Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 18 Mar 2025 09:36:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0https?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cultural/heritage/utils/RegexUtils.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/cultural/heritage/utils/RegexUtils.java b/src/main/java/com/cultural/heritage/utils/RegexUtils.java index d6f9f05..6ea95cd 100644 --- a/src/main/java/com/cultural/heritage/utils/RegexUtils.java +++ b/src/main/java/com/cultural/heritage/utils/RegexUtils.java @@ -56,14 +56,12 @@ public class RegexUtils { } - - - - - public static String encodeUrl(String input) { - String regex = "[\\s\\+\\?\\#\\&\\=\\/:\\(\\)\\!]"; - return input.replaceAll(regex, "_"); - } + /** + * 将除了点号以外的所有特殊字符替换都为下划线 + * @param input + * @return + */ + public static String encodeUrl(String input) { return input.replaceAll("[^\\w.]", "_"); }