java.util.regex
Class Matcher

Method Summary
java.util.regex.Matcher each(groovy.lang.Closure closure)
Process each matched substring of the given group matcher
java.lang.Object getAt(int idx)
Support the subscript operator, e
java.lang.String getAt(java.util.Collection indices)
Allows a List to be used as the indices to be used on a Matcher
int getCount()
Find the number of Strings matched to the given Matcher
static java.util.regex.Matcher getLastMatcher()
Get the last hidden matcher that system used to do a match
boolean hasGroup()
Check whether a Matcher contains a group or not
java.util.Iterator iterator()
void setIndex(int idx)
Set the position of the given Matcher to the given index
long size()
Provide the standard Groovy size method for a matcher
 
Method Detail

each

public java.util.regex.Matcher each(groovy.lang.Closure closure)
Process each matched substring of the given group matcher. The object passed to the closure is an array of strings, matched per a successful match.

Parameters:
closure - a closure.
Returns:
the matcher

getAt

public java.lang.Object getAt(int idx)
Support the subscript operator, e.g. matcher[index], for a regex Matcher.

For an example using no group match,

 def p = /ab[d|f]/ def m = "abcabdabeabf" =~ p for (i in 0.. 

For an example using group matches,

 def p = /(?:ab([c|d|e|f]))/ def m = "abcabdabeabf" =~ p for (i in 0.. 

For another example using group matches,

 def m = "abcabdabeabfabxyzabx" =~ /(?:ab([d|x-z]+))/ m.count.times { println( "m.groupCount() = " + m.groupCount()) println( " " + it + ": " + m[it] ) // m[it] is a List } 

Parameters:
idx - an index.
Returns:
object a matched String if no groups matched, list of matched groups otherwise.

getAt

public java.lang.String getAt(java.util.Collection indices)
Allows a List to be used as the indices to be used on a Matcher

Parameters:
indices - a Collection of indices.
Returns:
a String of the values at the given indices

getCount

public int getCount()
Find the number of Strings matched to the given Matcher.

Returns:
int the number of Strings matched to the given matcher.

getLastMatcher

public static java.util.regex.Matcher getLastMatcher()
Get the last hidden matcher that system used to do a match.

Returns:
the last regex matcher

hasGroup

public boolean hasGroup()
Check whether a Matcher contains a group or not.

Returns:
boolean true if matcher contains at least one group.

iterator

public java.util.Iterator iterator()

Returns:
an Iterator for a Matcher

setIndex

public void setIndex(int idx)
Set the position of the given Matcher to the given index.

Parameters:
idx - the index number.

size

public long size()
Provide the standard Groovy size method for a matcher.

Returns:
the matcher's size (count)