Main Page   Class Hierarchy   Compound List   Compound Members  

RE Class Reference

Regex wrapper class. More...

List of all members.

Public Methods

 RE (const string &pattern)
 Constructor.

bool match (const string &s)
string get_matched (const int i)
const int * get_span (const int i)
int get_nsub ()


Detailed Description

Regex wrapper class.

RE wraps the regex library by Henry Spencer, which is included in the aglib package.


Constructor & Destructor Documentation

RE::RE const string &    pattern
 

Constructor.

Compile the given "pattern"(a regular expression) into internal form for matches which will be performed later on.


Member Function Documentation

string RE::get_matched const int    i
 

Get i-th matched substring.

Parameters:
i  The index of substring to get.
Returns:
i-th substring
Calling this after a failed match will cause GetError exception. Out-of-range error detected and GetError will be thrown.

int RE::get_nsub  
 

Returns:
The number of subexpressions in the expression

const int* RE::get_span const int    i
 

Get the start and end index of i-th substring relative to the whole string.

Parameters:
i  The index of target substring.
Returns:
Array(pair) of integers. First one is the start index, and second one, the end index. The values in the array will be updated after another get_span() call.

bool RE::match const string &    s
 

Match given string "s" with the compiled expression. "True" is returned for "match success", "false" for "match failed." The exception MatchError doesn't mean "match failed."