libperun

Class std.re.Match

Synopsis

public final class Match

Represents a regular expression match.

Instances are only returned by the methods in std.re.Pattern.

Fields

Constructors

public Match(String subject,int startPos,int size,List< Match > groups);

INTERNAL. See std.re.Pattern. Construct the match with the specified parameters.

Methods

public int getStartPos();

Returns the index of the first character matching the expression.

public int getSize();

Returns the number of bytes matching the expression.

public String getValue();

Get the matched substring.

public Match opGet(int index);

Return a Match object for the specified parenthesized group in the expression, counting from 0.

public int getGroupCount();

Get the number of matched groups.

public String format(String template);

Create a formatted string based on the match.

In the template string, '\n' (where n is an integer) is replaced by the n'th group within this match. '\\' is replaced with a single '\'.

The sequence "\#" is replaced by nothing. It can be used if, for example, you want to enter digits directly after a group value: \0\#25