#include <pstring.h>
Inheritance diagram for PRegularExpression:
Constructors & destructors | |
enum | { Extended = 1, IgnoreCase = 2, AnchorNewLine = 4 } |
Flags for compiler options. More... | |
enum | { NotBeginningOfLine = 1, NotEndofLine = 2 } |
Flags for execution options. More... | |
PRegularExpression () | |
Create a new, empty, regular expression. | |
PRegularExpression (const PString &pattern, int flags=IgnoreCase) | |
Create and compile a new regular expression pattern. | |
PRegularExpression (const char *cpattern, int flags=IgnoreCase) | |
Create and compile a new regular expression pattern. | |
PRegularExpression (const PRegularExpression &) | |
Copy a regular expression. | |
PRegularExpression & | operator= (const PRegularExpression &) |
Assign a regular expression. | |
~PRegularExpression () | |
Release storage for the compiled regular expression. | |
Status functions | |
enum | ErrorCodes { NoError = 0, NoMatch, BadPattern, CollateError, BadClassType, BadEscape, BadSubReg, UnmatchedBracket, UnmatchedParen, UnmatchedBrace, BadBR, RangeError, OutOfMemory, BadRepitition, PrematureEnd, TooBig, UnmatchedRParen, NotCompiled } |
Error codes. More... | |
ErrorCodes | GetErrorCode () const |
Get the error code for the last Compile() or Execute() operation. | |
PString | GetErrorText () const |
Get the text description for the error of the last Compile() or Execute() operation. | |
const PString & | GetPattern () const |
Return the string which represents the pattern matched by the regular expression. | |
Public Member Functions | |
Overrides from class PObject | |
virtual void | PrintOn (ostream &strm) const |
Output the regular expression to the specified stream. | |
Compile & Execute functions | |
PBoolean | Compile (const PString &pattern, int flags=IgnoreCase) |
Compiler pattern. | |
PBoolean | Compile (const char *cpattern, int flags=IgnoreCase) |
Compiler pattern. | |
PBoolean | Execute (const PString &str, PINDEX &start, int flags=0) const |
Execute regular expression. | |
PBoolean | Execute (const PString &str, PINDEX &start, PINDEX &len, int flags=0) const |
Execute regular expression. | |
PBoolean | Execute (const char *cstr, PINDEX &start, int flags=0) const |
Execute regular expression. | |
PBoolean | Execute (const char *cstr, PINDEX &start, PINDEX &len, int flags=0) const |
Execute regular expression. | |
PBoolean | Execute (const PString &str, PIntArray &starts, int flags=0) const |
Execute regular expression. | |
PBoolean | Execute (const PString &str, PIntArray &starts, PIntArray &ends, int flags=0) const |
Execute regular expression. | |
PBoolean | Execute (const char *cstr, PIntArray &starts, int flags=0) const |
Execute regular expression. | |
PBoolean | Execute (const char *cstr, PIntArray &starts, PIntArray &ends, int flags=0) const |
Execute regular expression. | |
Static Public Member Functions | |
Miscellaneous functions | |
static PString | EscapeString (const PString &str) |
Escape all characters in the str parameter that have a special meaning within a regular expression. | |
Protected Attributes | |
PString | patternSaved |
int | flagsSaved |
void * | expression |
ErrorCodes | lastError |
The regular expression string is "compiled" into a form that is more efficient during the matching. This compiled form exists for the lifetime of the PRegularExpression instance.
anonymous enum |
anonymous enum |
Flags for execution options.
Error codes.
PRegularExpression::PRegularExpression | ( | ) |
Create a new, empty, regular expression.
PRegularExpression::PRegularExpression | ( | const PString & | pattern, | |
int | flags = IgnoreCase | |||
) |
Create and compile a new regular expression pattern.
pattern | Pattern to compile |
flags | Pattern match options |
PRegularExpression::PRegularExpression | ( | const char * | cpattern, | |
int | flags = IgnoreCase | |||
) |
Create and compile a new regular expression pattern.
cpattern | Pattern to compile |
flags | Pattern match options |
PRegularExpression::PRegularExpression | ( | const PRegularExpression & | ) |
Copy a regular expression.
PRegularExpression::~PRegularExpression | ( | ) |
Release storage for the compiled regular expression.
PBoolean PRegularExpression::Compile | ( | const char * | cpattern, | |
int | flags = IgnoreCase | |||
) |
Compiler pattern.
The pattern is compiled into an internal format to speed subsequent execution of the pattern match algorithm.
cpattern | Pattern to compile |
flags | Pattern match options |
Compiler pattern.
pattern | Pattern to compile |
flags | Pattern match options |
Escape all characters in the str
parameter that have a special meaning within a regular expression.
str | String to add esacpes to. |
PBoolean PRegularExpression::Execute | ( | const char * | cstr, | |
PIntArray & | starts, | |||
PIntArray & | ends, | |||
int | flags = 0 | |||
) | const |
Execute regular expression.
Execute the pattern match algorithm using the previously compiled pattern.
The starts
array is filled with as many matches as will fit into the array. If the the array size is zero then it is set to at least one for the first match found.
The ends
array is set to the ending position of each substring whose start is returned in the starts
array. This will always be set to the same size as that array.
cstr | Source string to search |
starts | List of match locations |
ends | List of match ends |
flags | Pattern match options |
Execute regular expression.
cstr | Source string to search |
starts | List of match locations |
flags | Pattern match options |
PBoolean PRegularExpression::Execute | ( | const PString & | str, | |
PIntArray & | starts, | |||
PIntArray & | ends, | |||
int | flags = 0 | |||
) | const |
Execute regular expression.
str | Source string to search |
starts | List of match locations |
ends | List of match ends |
flags | Pattern match options |
PBoolean PRegularExpression::Execute | ( | const PString & | str, | |
PIntArray & | starts, | |||
int | flags = 0 | |||
) | const |
Execute regular expression.
str | Source string to search |
starts | List of match locations |
flags | Pattern match options |
PBoolean PRegularExpression::Execute | ( | const char * | cstr, | |
PINDEX & | start, | |||
PINDEX & | len, | |||
int | flags = 0 | |||
) | const |
Execute regular expression.
cstr | Source string to search |
start | First match locations |
len | Length of match |
flags | Pattern match options |
PBoolean PRegularExpression::Execute | ( | const char * | cstr, | |
PINDEX & | start, | |||
int | flags = 0 | |||
) | const |
Execute regular expression.
cstr | Source string to search |
start | First match locations |
flags | Pattern match options |
PBoolean PRegularExpression::Execute | ( | const PString & | str, | |
PINDEX & | start, | |||
PINDEX & | len, | |||
int | flags = 0 | |||
) | const |
Execute regular expression.
str | Source string to search |
start | First match locations |
len | Length of match |
flags | Pattern match options |
Execute regular expression.
str | Source string to search |
start | First match locations |
flags | Pattern match options |
ErrorCodes PRegularExpression::GetErrorCode | ( | ) | const |
PString PRegularExpression::GetErrorText | ( | ) | const |
const PString& PRegularExpression::GetPattern | ( | ) | const [inline] |
Return the string which represents the pattern matched by the regular expression.
PRegularExpression& PRegularExpression::operator= | ( | const PRegularExpression & | ) |
Assign a regular expression.
virtual void PRegularExpression::PrintOn | ( | ostream & | strm | ) | const [virtual] |
Output the regular expression to the specified stream.
strm | I/O stream to output to. |
Reimplemented from PObject.
void* PRegularExpression::expression [protected] |
int PRegularExpression::flagsSaved [protected] |
ErrorCodes PRegularExpression::lastError [mutable, protected] |
PString PRegularExpression::patternSaved [protected] |