class PRegularExpression: public PObject

A class representing a regular expression that may be used for locating patterns in strings.

Inheritance:


Public

[more] Constructors & destructors
[more] Status functions
[more] Compile & Execute functions
[more] Miscellaneous functions


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions


Documentation

A class representing a regular expression that may be used for locating patterns in strings. 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.
o Constructors & destructors

o
Flags for compiler options.

o Extended
Use extended regular expressions

o IgnoreCase
Ignore case in search.

o AnchorNewLine
If this bit is set, then anchors do not match at newline characters in the string. If not set, then anchors do match at newlines.

o
Flags for execution options.

o NotBeginningOfLine
If this bit is set, then the beginning-of-line operator doesn't match the beginning of the string (presumably because it's not the beginning of a line). If not set, then the beginning-of-line operator does match the beginning of the string.

o NotEndofLine
Like NotBeginningOfLine, except for the end-of-line.

o PRegularExpression()
Create a new, empty, regular expression

o PRegularExpression( const PString & pattern, int flags = IgnoreCase )
Create and compile a new regular expression pattern.
Parameters:
pattern - Pattern to compile
flags - Pattern match options

o PRegularExpression( const char * cpattern, int flags = IgnoreCase )
Create and compile a new regular expression pattern.
Parameters:
cpattern - Pattern to compile
flags - Pattern match options

o ~PRegularExpression()
Release storage for the compiled regular expression.

o Status functions

oenum ErrorCodes
Error codes.

o NoError
Success.

o NoMatch
Didn't find a match (for regexec).

o BadPattern
Invalid pattern.

o CollateError
Not implemented.

o BadClassType
Invalid character class name.

o BadEscape
Trailing backslash.

o BadSubReg
Invalid back reference.

o UnmatchedBracket
Unmatched left bracket.

o UnmatchedParen
Parenthesis imbalance.

o UnmatchedBrace
Unmatched \{\}.

o BadBR
Invalid contents of \{\}.

o RangeError
Invalid range end.

o OutOfMemory
Ran out of memory.

o BadRepitition
No preceding re for repetition op.

o PrematureEnd
Premature end.

o TooBig
Compiled pattern bigger than 2^16 bytes.

o UnmatchedRParen
Unmatched ) or \); not returned from regcomp.

o NotCompiled
Miscellaneous error

oErrorCodes GetErrorCode() const
Get the error code for the last Compile() or Execute() operation.

Returns:
Error code.

oPString GetErrorText() const
Get the text description for the error of the last Compile() or Execute() operation.

Returns:
Error text string.

o Compile & Execute functions

oBOOL Compile( const PString & pattern, int flags = IgnoreCase )
Compiler pattern.
Parameters:
pattern - Pattern to compile
flags - Pattern match options

oBOOL 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.

Returns:
TRUE if successfully compiled.
Parameters:
cpattern - Pattern to compile
flags - Pattern match options

oBOOL Execute( const PString & str, PINDEX & start, int flags = 0 ) const
Execute regular expression
Parameters:
str - Source string to search
start - First match locations
flags - Pattern match options

oBOOL Execute( const PString & str, PINDEX & start, PINDEX & len, int flags = 0 ) const
Execute regular expression
Parameters:
str - Source string to search
start - First match locations
len - Length of match
flags - Pattern match options

oBOOL Execute( const char * cstr, PINDEX & start, int flags = 0 ) const
Execute regular expression
Parameters:
cstr - Source string to search
start - First match locations
flags - Pattern match options

oBOOL Execute( const char * cstr, PINDEX & start, PINDEX & len, int flags = 0 ) const
Execute regular expression
Parameters:
cstr - Source string to search
start - First match locations
len - Length of match
flags - Pattern match options

oBOOL Execute( const PString & str, PIntArray & starts, int flags = 0 ) const
Execute regular expression
Parameters:
str - Source string to search
starts - List of match locations
flags - Pattern match options

oBOOL Execute( const PString & str, PIntArray & starts, PIntArray & ends, int flags = 0 ) const
Execute regular expression
Parameters:
str - Source string to search
starts - List of match locations
ends - List of match ends
flags - Pattern match options

oBOOL Execute( const char * cstr, PIntArray & starts, int flags = 0 ) const
Execute regular expression
Parameters:
cstr - Source string to search
starts - List of match locations
flags - Pattern match options

oBOOL 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 substring whose start is returned in the starts array. This will always be set to the same size as that array.

Returns:
TRUE if successfully compiled.
Parameters:
cstr - Source string to search
starts - List of match locations
ends - List of match ends
flags - Pattern match options

o Miscellaneous functions

ostatic PString EscapeString( const PString & str )
Escape all characters in the str parameter that have a special meaning within a regular expression.

Returns:
String with additional escape ('\') characters.
Parameters:
str - String to add esacpes to.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.