Package org.pcre4j

Class Pcre4jUtils

java.lang.Object
org.pcre4j.Pcre4jUtils

public final class Pcre4jUtils extends Object
  • Method Details

    • getVersion

      public static String getVersion(org.pcre4j.api.IPcre2 api)
      Get the PCRE2 version.
      Parameters:
      api - the PCRE2 API
      Returns:
      the PCRE2 version
    • getUnicodeVersion

      public static String getUnicodeVersion(org.pcre4j.api.IPcre2 api)
      Get the Unicode version.
      Parameters:
      api - the PCRE2 API
      Returns:
      the Unicode version
    • isUnicodeSupported

      public static boolean isUnicodeSupported(org.pcre4j.api.IPcre2 api)
      Check if Unicode is supported.
      Parameters:
      api - the PCRE2 API
      Returns:
      true if Unicode is supported, false otherwise
    • getDefaultParenthesesNestingLimit

      public static int getDefaultParenthesesNestingLimit(org.pcre4j.api.IPcre2 api)
      Get the default parentheses nesting limit.
      Parameters:
      api - the PCRE2 API
      Returns:
      the default parentheses nesting limit
    • getDefaultNewline

      public static Pcre2Newline getDefaultNewline(org.pcre4j.api.IPcre2 api)
      Get the default newline sequence.
      Parameters:
      api - the PCRE2 API
      Returns:
      the default newline sequence
    • isBackslashCDisabled

      public static boolean isBackslashCDisabled(org.pcre4j.api.IPcre2 api)
      Check if the \C is disabled.
      Parameters:
      api - the PCRE2 API
      Returns:
      true if the \C is disabled, false otherwise
    • getDefaultMatchLimit

      public static int getDefaultMatchLimit(org.pcre4j.api.IPcre2 api)
      Get the default match limit.
      Parameters:
      api - the PCRE2 API
      Returns:
      the default match limit
    • getInternalLinkSize

      public static int getInternalLinkSize(org.pcre4j.api.IPcre2 api)
      Get the internal link size.
      Parameters:
      api - the PCRE2 API
      Returns:
      the internal link size
    • getJitTarget

      public static String getJitTarget(org.pcre4j.api.IPcre2 api)
      Get the JIT target.
      Parameters:
      api - the PCRE2 API
      Returns:
      the JIT target or null if JIT is not supported
    • isJitSupported

      public static boolean isJitSupported(org.pcre4j.api.IPcre2 api)
      Check if JIT is supported.
      Parameters:
      api - the PCRE2 API
      Returns:
      true if JIT is supported, false otherwise
    • getDefaultHeapLimit

      public static int getDefaultHeapLimit(org.pcre4j.api.IPcre2 api)
      Get the default heap memory limit.
      Parameters:
      api - the PCRE2 API
      Returns:
      the default heap memory limit
    • getDefaultDepthLimit

      public static int getDefaultDepthLimit(org.pcre4j.api.IPcre2 api)
      Get the default backtracking depth limit.
      Parameters:
      api - the PCRE2 API
      Returns:
      the default backtracking depth limit
    • getCompiledWidths

      public static EnumSet<Pcre2UtfWidth> getCompiledWidths(org.pcre4j.api.IPcre2 api)
      Get which of the character widths the PCRE2 library was compiled with.
      Parameters:
      api - the PCRE2 API
      Returns:
      the compiled character width (8, 16, or 32)
    • convertCharacterIndexToByteOffset

      public static int convertCharacterIndexToByteOffset(String input, int index)
      Convert a character index to a byte offset.
      Parameters:
      input - the input string
      index - the character index
      Returns:
      the byte offset
    • getDefaultBsr

      public static Pcre2Bsr getDefaultBsr(org.pcre4j.api.IPcre2 api)
      Get what \R matches by default.
      Parameters:
      api - the PCRE2 API
      Returns:
      the default \R match
    • getErrorMessage

      public static String getErrorMessage(org.pcre4j.api.IPcre2 api, int errorcode)
      Get the error message for the given error code.
      Parameters:
      api - the PCRE2 API
      errorcode - the error code
      Returns:
      the error message
    • getGroupNames

      public static String[] getGroupNames(Pcre2Code code)
      Get the group names for the given code.
      Parameters:
      code - the PCRE2 compiled pattern
      Returns:
      an array where the index is the group number and the value is the group name or null if the group has no name
    • getMatchGroups

      public static String[] getMatchGroups(Pcre2Code code, String subject, Pcre2MatchData matchData)
      Get the match groups
      Parameters:
      code - the compiled pattern the match was performed with
      subject - the subject string the match was performed against
      matchData - the match data with the match results
      Returns:
      an array of strings where the index is the group number and the value is the matched group or null
    • getMatchGroups

      public static String[] getMatchGroups(Pcre2Code code, String subject, long[] ovector)
      Get the match groups
      Parameters:
      code - the compiled pattern the match was performed with
      subject - the subject string the match was performed against
      ovector - an array of offset pairs corresponding to the match results
      Returns:
      an array of strings where the index is the group number and the value is the matched group or null
    • getNamedMatchGroups

      public static Map<String,String> getNamedMatchGroups(Pcre2Code code, String subject, Pcre2MatchData matchData)
      Get the match named groups
      Parameters:
      code - the compiled pattern the match was performed with
      subject - the subject string the match was performed against
      matchData - the match data with the match results
      Returns:
      a map of group names to the matched group or null
    • getNamedMatchGroups

      public static Map<String,String> getNamedMatchGroups(Pcre2Code code, String subject, long[] ovector)
      Get the match named groups
      Parameters:
      code - the compiled pattern the match was performed with
      subject - the subject string the match was performed against
      ovector - an array of offset pairs corresponding to the match results
      Returns:
      a map of group names to the matched group or null
    • convertOvectorToStringIndices

      public static int[] convertOvectorToStringIndices(String subject, long[] ovector)
      Convert the byte-based ovector offset pairs to string index pairs
      Parameters:
      subject - the string to which the ovector values correspond
      ovector - the byte-based ovector offset pairs
      Returns:
      a string index pairs
    • convertOvectorToStringIndices

      public static int[] convertOvectorToStringIndices(String subject, byte[] subjectUtf8, long[] ovector)
      Convert the byte-based ovector offset pairs to string index pairs
      Parameters:
      subject - the string to which the ovector values correspond
      subjectUtf8 - the string encoded as UTF-8 byte[]
      ovector - the byte-based ovector offset pairs
      Returns:
      a string index pairs