Class RegexpHelper

java.lang.Object
dev.frostlake.functions.scalar.string.RegexpHelper

public final class RegexpHelper extends Object
Shared helpers for the REGEXP_* functions: translating Snowflake's regex_parameters flag string to Pattern flags, detecting the e (extract) flag, and converting a Snowflake replacement string (backreferences \0–\9) to Java's replacement syntax.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Pattern
    compile(String pattern, String parameters)
    Compile a Snowflake pattern honoring the i/m/s flags in parameters, cached by (flags, pattern) — normally constant across rows.
    static boolean
    hasExtract(String parameters)
    Whether the e (extract submatch) flag is present in the parameters string.
    static int
    toJavaFlags(String parameters)
    Map Snowflake regex_parameters to java.util.regex flags: i → CASE_INSENSITIVE, m → MULTILINE, s → DOTALL.
    static String
    Convert a Snowflake replacement string to a Matcher.appendReplacement replacement: a backslash-digit (\1) becomes $1; \\ a literal backslash; a bare $ or trailing \ is escaped so it is treated literally.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • toJavaFlags

      public static int toJavaFlags(String parameters)
      Map Snowflake regex_parameters to java.util.regex flags: i → CASE_INSENSITIVE, m → MULTILINE, s → DOTALL. c (case-sensitive, the default) and e (handled by the caller) contribute no flag; unknown characters are ignored.
    • hasExtract

      public static boolean hasExtract(String parameters)
      Whether the e (extract submatch) flag is present in the parameters string.
    • compile

      public static Pattern compile(String pattern, String parameters)
      Compile a Snowflake pattern honoring the i/m/s flags in parameters, cached by (flags, pattern) — normally constant across rows.
    • translateReplacement

      public static String translateReplacement(String replacement)
      Convert a Snowflake replacement string to a Matcher.appendReplacement replacement: a backslash-digit (\1) becomes $1; \\ a literal backslash; a bare $ or trailing \ is escaped so it is treated literally.