Package org.pcre4j

Class Pcre4jUtils

java.lang.Object
org.pcre4j.Pcre4jUtils

public final class Pcre4jUtils extends Object
  • Method Details

    • 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
      ovector - the byte-based ovector offset pairs
      Returns:
      a string index pairs