public class JRegexIterator extends java.lang.Object implements RegexIterator, LastPositionFinder
Constructor and Description |
---|
JRegexIterator(java.lang.String str,
java.util.regex.Pattern pattern)
Construct a RegexIterator.
|
Modifier and Type | Method and Description |
---|---|
int |
getLength()
Get the last position (that is, the number of items in the sequence).
|
int |
getNumberOfGroups()
Get the number of captured groups
|
UnicodeString |
getRegexGroup(int number)
Get a substring that matches a parenthesised group within the regular expression
|
boolean |
isMatching()
Determine whether the current item is a matching item or a non-matching item
|
StringValue |
next()
Get the next item in the sequence
|
void |
processMatchingSubstring(RegexMatchHandler action)
Process a matching substring, performing specified actions at the start and end of each captured
subgroup.
|
boolean |
supportsGetLength()
Ask whether this iterator supports use of the
LastPositionFinder.getLength() method. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, discharge
public JRegexIterator(java.lang.String str, java.util.regex.Pattern pattern)
str
- the string to be analysedpattern
- the regular expressionpublic boolean supportsGetLength()
LastPositionFinder
LastPositionFinder.getLength()
method. This
method should always be called before calling LastPositionFinder.getLength()
, because an iterator
that implements this interface may support use of LastPositionFinder.getLength()
in some situations
and not in otherssupportsGetLength
in interface LastPositionFinder
LastPositionFinder.getLength()
method can be called to determine the length
of the underlying sequence.public int getLength()
LastPositionFinder
LastPositionFinder.supportsGetLength()
has been called
and has returned true.getLength
in interface LastPositionFinder
public StringValue next()
next
in interface SequenceIterator
next
in interface RegexIterator
public boolean isMatching()
isMatching
in interface RegexIterator
public UnicodeString getRegexGroup(int number)
getRegexGroup
in interface RegexIterator
number
- the number of the group to be obtainedpublic int getNumberOfGroups()
getNumberOfGroups
in interface RegexIterator
public void processMatchingSubstring(RegexMatchHandler action) throws XPathException
processMatchingSubstring
in interface RegexIterator
action
- defines the processing to be performed at the start and end of a groupXPathException
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.