From 7f8489991316b173d656f10f98628806173abe91 Mon Sep 17 00:00:00 2001 From: Nikita Akilov <26031301+n5a5@users.noreply.github.com> Date: Mon, 23 Dec 2024 19:10:41 +0100 Subject: [PATCH] dbeaver/pro#3893 extract whitespace pattern to common utils --- .../org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java b/modules/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java index 8edb6b0..10af8d7 100644 --- a/modules/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java +++ b/modules/org.jkiss.utils/src/org/jkiss/utils/CommonUtils.java @@ -31,6 +31,10 @@ * Common utils */ public class CommonUtils { + /** + * A pattern that matches one or more whitespace characters. + */ + public static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+"); public static final char PARAGRAPH_CHAR = (char) 182; @@ -873,7 +877,7 @@ public static String trim(String str) { } public static String compactWhiteSpaces(String str) { - return str.replaceAll("\\s+", " "); + return WHITESPACE_PATTERN.matcher(str).replaceAll(" "); } public static String getSingleLineString(String displayString) {