#include <FXRex.h>
When parsing a regular expression pattern, the mode parameter is the bitwise OR of a set of flags and affects the match algorithm. Passing the flag REX_CAPTURE enables capturing parentheses and back references. The flag REX_ICASE enables case-insensitive matching. When the flag REX_NEWLINE is passed, newlines are treated like normal characters; otherwise, newline is NOT matched except when explicitly part of a character class. The flag REX_VERBATIM disables all special character interpretation.
When matching a compiled pattern, the mode parameter is the bitwise OR of a set of flags that affects how the match is performed. Passing the flag REX_BACKWARD causes the match to proceed backwards through the subject string. Passing the flags REX_NOT_BOL and/or REX_NOT_EOL causes the begin and end of the subject string NOT to be considered a line start or line end. The flag REX_NOT_EMPTY causes a match to fail if the empty string was matched.
Public Member Functions | |
FXRex () | |
FXRex (const FXRex &orig) | |
FXRex (const FXchar *pattern, FXint mode=REX_NORMAL, FXRexError *error=NULL) | |
FXRex (const FXString &pattern, FXint mode=REX_NORMAL, FXRexError *error=NULL) | |
FXRex & | operator= (const FXRex &orig) |
bool | empty () const |
FXRexError | parse (const FXchar *pattern, FXint mode=REX_NORMAL) |
FXRexError | parse (const FXString &pattern, FXint mode=REX_NORMAL) |
bool | match (const FXchar *string, FXint len, FXint *beg=NULL, FXint *end=NULL, FXint mode=REX_FORWARD, FXint npar=1, FXint fm=0, FXint to=2147483647) const |
bool | match (const FXString &string, FXint *beg=NULL, FXint *end=NULL, FXint mode=REX_FORWARD, FXint npar=1, FXint fm=0, FXint to=2147483647) const |
bool | operator== (const FXRex &rex) const |
bool | operator!= (const FXRex &rex) const |
~FXRex () | |
Static Public Member Functions | |
static FXString | substitute (const FXchar *string, FXint len, FXint *beg, FXint *end, const FXString &replace, FXint npar=1) |
static FXString | substitute (const FXString &string, FXint *beg, FXint *end, const FXString &replace, FXint npar=1) |
static const FXchar * | getError (FXRexError err) |
Friends | |
FXAPI FXStream & | operator<< (FXStream &store, const FXRex &s) |
FXAPI FXStream & | operator>> (FXStream &store, FXRex &s) |
FX::FXRex::FXRex | ( | ) | [inline] |
Construct empty regular expression object.
FX::FXRex::FXRex | ( | const FXRex & | orig | ) |
Copy regular expression object.
FX::FXRex::FXRex | ( | const FXchar * | pattern, | |
FXint | mode = REX_NORMAL , |
|||
FXRexError * | error = NULL | |||
) |
Compile expression from pattern; if error is not NULL, error code is returned.
FX::FXRex::FXRex | ( | const FXString & | pattern, | |
FXint | mode = REX_NORMAL , |
|||
FXRexError * | error = NULL | |||
) |
Compile expression from pattern; if error is not NULL, error code is returned.
FX::FXRex::~FXRex | ( | ) |
Delete.
bool FX::FXRex::empty | ( | ) | const [inline] |
See if regular expression is empty; the regular expression will be empty when it is unable to parse a pattern due to a syntax error.
FXRexError FX::FXRex::parse | ( | const FXchar * | pattern, | |
FXint | mode = REX_NORMAL | |||
) |
Parse pattern, return error code if syntax error is found.
FXRexError FX::FXRex::parse | ( | const FXString & | pattern, | |
FXint | mode = REX_NORMAL | |||
) |
Parse pattern, return error code if syntax error is found.
bool FX::FXRex::match | ( | const FXchar * | string, | |
FXint | len, | |||
FXint * | beg = NULL , |
|||
FXint * | end = NULL , |
|||
FXint | mode = REX_FORWARD , |
|||
FXint | npar = 1 , |
|||
FXint | fm = 0 , |
|||
FXint | to = 2147483647 | |||
) | const |
Match a subject string of length len, returning TRUE if a match is found and FALSE otherwise. The entire pattern is captured in beg[0] and end[0], where beg[0] refers to the position of the first matched character and end[0] refers to the position after the last matched character. Sub expressions from capturing parenthesis i are returned in beg[i] and end[i].
bool FX::FXRex::match | ( | const FXString & | string, | |
FXint * | beg = NULL , |
|||
FXint * | end = NULL , |
|||
FXint | mode = REX_FORWARD , |
|||
FXint | npar = 1 , |
|||
FXint | fm = 0 , |
|||
FXint | to = 2147483647 | |||
) | const |
Search for match in a string.
static FXString FX::FXRex::substitute | ( | const FXchar * | string, | |
FXint | len, | |||
FXint * | beg, | |||
FXint * | end, | |||
const FXString & | replace, | |||
FXint | npar = 1 | |||
) | [static] |
After performing a regular expression match with capturing parentheses, a substitution string is build from the replace string, where where "&" is replaced by the entire matched pattern, and "\1" through "\9" are replaced by captured expressions. The original source string and its length, and the match arrays beg and end must be passed.
static FXString FX::FXRex::substitute | ( | const FXString & | string, | |
FXint * | beg, | |||
FXint * | end, | |||
const FXString & | replace, | |||
FXint | npar = 1 | |||
) | [static] |
Return substitution string.
static const FXchar* FX::FXRex::getError | ( | FXRexError | err | ) | [inline, static] |
Returns error code for given error.
bool FX::FXRex::operator== | ( | const FXRex & | rex | ) | const |
Comparison operators.