Package org.pcre4j
Class Pcre4jUtils
java.lang.Object
org.pcre4j.Pcre4jUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]convertOvectorToStringIndices(String subject, byte[] subjectUtf8, long[] ovector) Convert the byte-based ovector offset pairs to string index pairsstatic int[]convertOvectorToStringIndices(String subject, long[] ovector) Convert the byte-based ovector offset pairs to string index pairsstatic StringgetErrorMessage(org.pcre4j.api.IPcre2 api, int errorcode) Get the error message for the given error code.static String[]getGroupNames(Pcre2Code code) Get the group names for the given code.static String[]getMatchGroups(Pcre2Code code, String subject, long[] ovector) Get the match groupsstatic String[]getMatchGroups(Pcre2Code code, String subject, Pcre2MatchData matchData) Get the match groupsgetNamedMatchGroups(Pcre2Code code, String subject, long[] ovector) Get the match named groupsgetNamedMatchGroups(Pcre2Code code, String subject, Pcre2MatchData matchData) Get the match named groups
-
Method Details
-
getErrorMessage
Get the error message for the given error code.- Parameters:
api- the PCRE2 APIerrorcode- the error code- Returns:
- the error message
-
getGroupNames
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
nullif the group has no name
-
getMatchGroups
Get the match groups- Parameters:
code- the compiled pattern the match was performed withsubject- the subject string the match was performed againstmatchData- 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
Get the match groups- Parameters:
code- the compiled pattern the match was performed withsubject- the subject string the match was performed againstovector- 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 withsubject- the subject string the match was performed againstmatchData- 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 withsubject- the subject string the match was performed againstovector- an array of offset pairs corresponding to the match results- Returns:
- a map of group names to the matched group or
null
-
convertOvectorToStringIndices
Convert the byte-based ovector offset pairs to string index pairs- Parameters:
subject- the string to which the ovector values correspondovector- 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 correspondovector- the byte-based ovector offset pairs- Returns:
- a string index pairs
-