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.]", "_"); }