From 44c3cc46367520f780537716236e0bed3b9537e6 Mon Sep 17 00:00:00 2001 From: benjy3gg Date: Thu, 2 May 2024 21:55:28 +0200 Subject: [PATCH] fix: Use Java instead of Kotlin Regex to improve reliability (#628) If Kotlin Regex would be used, then apps need to have the Kotlin libraries for Regex to work which isn't always the case. --- .../main/java/app/revanced/integrations/shared/Utils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/shared/Utils.java b/app/src/main/java/app/revanced/integrations/shared/Utils.java index bdad852f..09e3dcba 100644 --- a/app/src/main/java/app/revanced/integrations/shared/Utils.java +++ b/app/src/main/java/app/revanced/integrations/shared/Utils.java @@ -28,6 +28,7 @@ import androidx.annotation.Nullable; import java.text.Bidi; import java.util.*; +import java.util.regex.Pattern; import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.concurrent.SynchronousQueue; @@ -36,7 +37,6 @@ import java.util.concurrent.TimeUnit; import app.revanced.integrations.shared.settings.BooleanSetting; import app.revanced.integrations.shared.settings.preference.ReVancedAboutPreference; -import kotlin.text.Regex; public class Utils { @@ -474,14 +474,14 @@ public class Utils { } } - private static final Regex punctuationRegex = new Regex("\\p{P}+"); + private static final Pattern punctuationPattern = Pattern.compile("\\p{P}+"); /** * Strips all punctuation and converts to lower case. A null parameter returns an empty string. */ public static String removePunctuationConvertToLowercase(@Nullable CharSequence original) { if (original == null) return ""; - return punctuationRegex.replace(original, "").toLowerCase(); + return punctuationPattern.matcher(original).replaceAll("").toLowerCase(); } /**