Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix: Use Java instead of Kotlin Regex to improve reliability (#628)
Browse files Browse the repository at this point in the history
If Kotlin Regex would be used, then apps need to have the Kotlin libraries for Regex to work which isn't always the case.
  • Loading branch information
benjy3gg authored May 2, 2024
1 parent 07fe660 commit 44c3cc4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/app/revanced/integrations/shared/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

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;
Expand All @@ -36,7 +37,6 @@

import app.revanced.integrations.shared.settings.BooleanSetting;
import app.revanced.integrations.shared.settings.preference.ReVancedAboutPreference;
import kotlin.text.Regex;

public class Utils {

Expand Down Expand Up @@ -474,14 +474,14 @@ static Sort fromKey(@Nullable String key, @NonNull Sort defaultSort) {
}
}

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();
}

/**
Expand Down

0 comments on commit 44c3cc4

Please sign in to comment.