Grammatica
Public Member Functions | List of all members
PerCederberg.Grammatica.Runtime.RE.Matcher Class Reference

A regular expression string matcher. More...

Public Member Functions

bool IsCaseInsensitive ()
 Checks if this matcher compares in case-insensitive mode. More...
 
void Reset ()
 Resets the information about the last match. More...
 
void Reset (string str)
 Resets the matcher for use with a new input string. More...
 
void Reset (ReaderBuffer buffer)
 Resets the matcher for use with a new look-ahead character input stream. More...
 
int Start ()
 Returns the start position of the latest match. More...
 
int End ()
 Returns the end position of the latest match. More...
 
int Length ()
 Returns the length of the latest match. More...
 
bool HasReadEndOfString ()
 Checks if the end of the string was encountered during the last match attempt. More...
 
bool MatchFromBeginning ()
 Attempts to find a match starting at the beginning of the string. More...
 
bool MatchFrom (int pos)
 Attempts to find a match starting at the specified position in the string. More...
 
override string ToString ()
 Returns the latest matched string. More...
 

Detailed Description

A regular expression string matcher.

This class handles the matching of a specific string with a specific regular expression. It contains state information about the matching process, as for example the position of the latest match, and a number of flags that were set. This class is not thread-safe.

Author
Per Cederberg
Version
1.5

Member Function Documentation

int PerCederberg.Grammatica.Runtime.RE.Matcher.End ( )
inline

Returns the end position of the latest match.

This is one character after the match end, i.e. the first character after the match. If no match has been encountered, this method returns the same value as start().

Returns
the end position of the latest match
bool PerCederberg.Grammatica.Runtime.RE.Matcher.HasReadEndOfString ( )
inline

Checks if the end of the string was encountered during the last match attempt.

This flag signals that more input may be needed in order to get a match (or a longer match).

Returns
true if the end of string was encountered, or false otherwise
bool PerCederberg.Grammatica.Runtime.RE.Matcher.IsCaseInsensitive ( )
inline

Checks if this matcher compares in case-insensitive mode.

Returns
true if the matching is case-insensitive, or false otherwise
Since
1.5
int PerCederberg.Grammatica.Runtime.RE.Matcher.Length ( )
inline

Returns the length of the latest match.

Returns
the length of the latest match, or -1 if no match was found
bool PerCederberg.Grammatica.Runtime.RE.Matcher.MatchFrom ( int  pos)
inline

Attempts to find a match starting at the specified position in the string.

Parameters
posthe starting position of the match
Returns
true if a match was found, or false otherwise
Exceptions
IOExceptionif an I/O error occurred while reading an input stream
bool PerCederberg.Grammatica.Runtime.RE.Matcher.MatchFromBeginning ( )
inline

Attempts to find a match starting at the beginning of the string.

Returns
true if a match was found, or false otherwise
Exceptions
IOExceptionif an I/O error occurred while reading an input stream
void PerCederberg.Grammatica.Runtime.RE.Matcher.Reset ( )
inline

Resets the information about the last match.

This will clear all flags and set the match length to a negative value. This method is automatically called before starting a new match.

void PerCederberg.Grammatica.Runtime.RE.Matcher.Reset ( string  str)
inline

Resets the matcher for use with a new input string.

This will clear all flags and set the match length to a negative value.

Parameters
strthe new string to work with
Since
1.5
void PerCederberg.Grammatica.Runtime.RE.Matcher.Reset ( ReaderBuffer  buffer)
inline

Resets the matcher for use with a new look-ahead character input stream.

This will clear all flags and set the match length to a negative value.

Parameters
bufferthe character input buffer
Since
1.5
int PerCederberg.Grammatica.Runtime.RE.Matcher.Start ( )
inline

Returns the start position of the latest match.

If no match has been encountered, this method returns zero (0).

Returns
the start position of the latest match
override string PerCederberg.Grammatica.Runtime.RE.Matcher.ToString ( )
inline

Returns the latest matched string.

If no string has been matched, an empty string will be returned.

Returns
the latest matched string

The documentation for this class was generated from the following file: