public class JavaRegularExpression extends java.lang.Object implements RegularExpression
Note that in SaxonCS, this class is emulated by code that invokes the .NET regex engine, which has different rules. In this case the ";n" flag activates this option.
| Constructor and Description |
|---|
JavaRegularExpression(UnicodeString javaRegex,
java.lang.String flags)
Create a regular expression, starting with an already-translated Java regex.
|
| Modifier and Type | Method and Description |
|---|---|
RegexIterator |
analyze(UnicodeString input)
Use this regular expression to analyze an input string, in support of the XSLT
analyze-string instruction.
|
boolean |
containsMatch(UnicodeString input)
Determine whether the regular expression contains a match for a given string
|
int |
getFlagBits()
Get the flag bits as used by the Java regular expression engine
|
java.lang.String |
getFlags()
Get the flags used at the time the regular expression was compiled.
|
java.lang.String |
getJavaRegularExpression()
Get the Java regular expression (after translation from an XPath regex, but before compilation)
|
boolean |
isPlatformNative()
Ask whether the regular expression is using platform-native syntax (Java or .NET), or XPath syntax
|
boolean |
matches(UnicodeString input)
Determine whether the regular expression matches a given string in its entirety
|
UnicodeString |
replace(UnicodeString input,
UnicodeString replacement)
Replace all substrings of a supplied input string that match the regular expression
with a replacement string.
|
UnicodeString |
replaceWith(UnicodeString input,
java.util.function.Function<UnicodeString,UnicodeString> replacement)
Replace all substrings of a supplied input string that match the regular expression
with a replacement string.
|
static int |
setFlags(java.lang.CharSequence inFlags)
Set the Java flags from the supplied XPath flags.
|
AtomicIterator |
tokenize(UnicodeString input)
Use this regular expression to tokenize an input string.
|
public JavaRegularExpression(UnicodeString javaRegex, java.lang.String flags) throws XPathException
javaRegex - the regular expression after translation to Java notationflags - the user-specified flags (prior to any semicolon)XPathExceptionpublic java.lang.String getJavaRegularExpression()
public int getFlagBits()
public RegexIterator analyze(UnicodeString input)
analyze in interface RegularExpressioninput - the string to which the regular expression is to be appliedpublic boolean containsMatch(UnicodeString input)
containsMatch in interface RegularExpressioninput - the string to matchpublic boolean matches(UnicodeString input)
matches in interface RegularExpressioninput - the string to matchpublic UnicodeString replace(UnicodeString input, UnicodeString replacement) throws XPathException
replace in interface RegularExpressioninput - the input string on which replacements are to be performedreplacement - the replacement string in the format of the XPath replace() functionXPathException - if the replacement string is invalidpublic UnicodeString replaceWith(UnicodeString input, java.util.function.Function<UnicodeString,UnicodeString> replacement) throws XPathException
replaceWith in interface RegularExpressioninput - the input string on which replacements are to be performedreplacement - a function that is called once for each matching substring, and
that returns a replacement for that substringXPathException - if the replacement string is invalidpublic AtomicIterator tokenize(UnicodeString input)
tokenize in interface RegularExpressioninput - the string to be tokenizedpublic static int setFlags(java.lang.CharSequence inFlags)
throws XPathException
d - UNIX_LINES
m - MULTILINE
i - CASE_INSENSITIVE
s - DOTALL
x - COMMENTS
u - UNICODE_CASE
q - LITERAL
c - CANON_EQ
inFlags - the flags as a string, e.g. "im"XPathException - if the supplied value contains an unrecognized flag characterPatternpublic java.lang.String getFlags()
getFlags in interface RegularExpressionpublic boolean isPlatformNative()
isPlatformNative in interface RegularExpressionCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.