Package org.pcre4j
Class Pcre4jUtils
java.lang.Object
org.pcre4j.Pcre4jUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic intconvertCharacterIndexToByteOffset(String input, int index) Convert a character index to a byte offset.static 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 EnumSet<Pcre2UtfWidth> getCompiledWidths(org.pcre4j.api.IPcre2 api) Get which of the character widths the PCRE2 library was compiled with.static Pcre2BsrgetDefaultBsr(org.pcre4j.api.IPcre2 api) Get what \R matches by default.static intgetDefaultDepthLimit(org.pcre4j.api.IPcre2 api) Get the default backtracking depth limit.static intgetDefaultHeapLimit(org.pcre4j.api.IPcre2 api) Get the default heap memory limit.static intgetDefaultMatchLimit(org.pcre4j.api.IPcre2 api) Get the default match limit.static Pcre2NewlinegetDefaultNewline(org.pcre4j.api.IPcre2 api) Get the default newline sequence.static intgetDefaultParenthesesNestingLimit(org.pcre4j.api.IPcre2 api) Get the default parentheses nesting limit.static 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 intgetInternalLinkSize(org.pcre4j.api.IPcre2 api) Get the internal link size.static StringgetJitTarget(org.pcre4j.api.IPcre2 api) Get the JIT target.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 groupsstatic StringgetUnicodeVersion(org.pcre4j.api.IPcre2 api) Get the Unicode version.static StringgetVersion(org.pcre4j.api.IPcre2 api) Get the PCRE2 version.static booleanisBackslashCDisabled(org.pcre4j.api.IPcre2 api) Check if the \C is disabled.static booleanisJitSupported(org.pcre4j.api.IPcre2 api) Check if JIT is supported.static booleanisUnicodeSupported(org.pcre4j.api.IPcre2 api) Check if Unicode is supported.
-
Method Details
-
getVersion
Get the PCRE2 version.- Parameters:
api- the PCRE2 API- Returns:
- the PCRE2 version
-
getUnicodeVersion
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:
trueif Unicode is supported,falseotherwise
-
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
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:
trueif the \C is disabled,falseotherwise
-
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
Get the JIT target.- Parameters:
api- the PCRE2 API- Returns:
- the JIT target or
nullif 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:
trueif JIT is supported,falseotherwise
-
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
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
Convert a character index to a byte offset.- Parameters:
input- the input stringindex- the character index- Returns:
- the byte offset
-
getDefaultBsr
Get what \R matches by default.- Parameters:
api- the PCRE2 API- Returns:
- the default \R match
-
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 correspondsubjectUtf8- the string encoded as UTF-8byte[]ovector- the byte-based ovector offset pairs- Returns:
- a string index pairs
-