From 4eb8a9f9daadded63a06be9116e68e93ce761e5d Mon Sep 17 00:00:00 2001 From: j-dimension Date: Wed, 10 Jan 2024 22:09:13 +0100 Subject: [PATCH] string replacement without regex --- .../jlawyer/client/utils/FileUtils.java | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java index b9413b57a..4c6414ce6 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/utils/FileUtils.java @@ -853,39 +853,39 @@ public static String getNewFileName(String currentFileName, boolean datetimePref public static String sanitizeFileName(String fileName) { String name = fileName; - name = name.replaceAll(",", " "); - name = name.replaceAll("\"", ""); - name = name.replaceAll("§", " "); - name = name.replaceAll("%", " "); - name = name.replaceAll("&", "_"); - name = name.replaceAll("/", "_"); - name = name.replaceAll("=", "_"); - name = name.replaceAll("\\?", " "); - name = name.replaceAll("\\{", "("); - name = name.replaceAll("\\}", ")"); - name = name.replaceAll("\\[", "("); - name = name.replaceAll("\\]", ")"); - name = name.replaceAll("\\\\", "_"); - name = name.replaceAll("\\*", "-"); - name = name.replaceAll("#", "-"); - name = name.replaceAll("'", ""); - name = name.replaceAll(":", " "); - name = name.replaceAll(";", " "); - name = name.replaceAll(">", ""); - name = name.replaceAll("<", ""); - name = name.replaceAll("\\|", "_"); + name = name.replace(",", " "); + name = name.replace("\"", ""); + name = name.replace("§", " "); + name = name.replace("%", " "); + name = name.replace("&", "_"); + name = name.replace("/", "_"); + name = name.replace("=", "_"); + name = name.replace("?", " "); + name = name.replace("{", "("); + name = name.replace("}", ")"); + name = name.replace("[", "("); + name = name.replace("]", ")"); + name = name.replace("\\", "_"); + name = name.replace("*", "-"); + name = name.replace("#", "-"); + name = name.replace("'", ""); + name = name.replace(":", " "); + name = name.replace(";", " "); + name = name.replace(">", ""); + name = name.replace("<", ""); + name = name.replace("|", "_"); return name.trim(); } public static String sanitizeAttachmentName(String fileName) { String name = sanitizeFileName(fileName); - name = name.replaceAll("ä", "ae"); - name = name.replaceAll("ö", "oe"); - name = name.replaceAll("ü", "ue"); - name = name.replaceAll("Ä", "Ae"); - name = name.replaceAll("Ö", "Oe"); - name = name.replaceAll("Ü", "Ue"); - name = name.replaceAll("ß", "ss"); + name = name.replace("ä", "ae"); + name = name.replace("ö", "oe"); + name = name.replace("ü", "ue"); + name = name.replace("Ä", "Ae"); + name = name.replace("Ö", "Oe"); + name = name.replace("Ü", "Ue"); + name = name.replace("ß", "ss"); name=name.trim(); if(name.indexOf('.')==0) name="Anhang_"+System.currentTimeMillis()+name; @@ -894,8 +894,8 @@ public static String sanitizeAttachmentName(String fileName) { public static String sanitizeFolderName(String folderName) { String sanitized = sanitizeFileName(folderName); - sanitized = sanitized.replaceAll(" ", " "); - sanitized = sanitized.replaceAll(" ", " "); + sanitized = sanitized.replace(" ", " "); + sanitized = sanitized.replace(" ", " "); return sanitized; }