libcommonc++  0.7
RegExp Class Reference

A regular expression. More...

#include <RegExp.h++>

Public Member Functions

 RegExp ()
 Construct a new RegExp. More...
 
 RegExp (const RegExp &other)
 Copy constructor. More...
 
 ~RegExp ()
 Destructor. More...
 
void setPattern (const char *pattern, bool caseInsensitive=false)
 Set the regular expression pattern. More...
 
void setPattern (const String &pattern, bool caseInsensitive=false)
 Set the regular expression pattern. More...
 
String getPattern () const
 Get the regular expression pattern. More...
 
String toString () const
 Get a String representation of the RegExp. More...
 
bool match (const String &text) const
 Perform a pattern match against some text. More...
 
bool match (const String &text, RegExpMatch matches[], int numMatches) const
 Perform a pattern match against some text, returning submatches. More...
 
RegExpoperator= (const RegExp &other)
 Assignment operator. More...
 
bool isNull () const
 Determine if this regular expression has a null pattern. More...
 
bool operator! () const
 Determine if this regular expression has a null pattern. More...
 

Static Public Member Functions

static String escapeMeta (const String &text)
 Escape all metacharacters in a String. More...
 

Detailed Description

A regular expression.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ RegExp() [1/2]

RegExp ( )

Construct a new RegExp.

◆ RegExp() [2/2]

RegExp ( const RegExp other)

Copy constructor.

◆ ~RegExp()

~RegExp ( )

Destructor.

Member Function Documentation

◆ escapeMeta()

String escapeMeta ( const String text)
static

Escape all metacharacters in a String.

Parameters
textThe String to escape.
Returns
A copy of the string with all metacharacters escaped.

◆ getPattern()

String getPattern ( ) const
inline

Get the regular expression pattern.

◆ isNull()

bool isNull ( ) const
inline

Determine if this regular expression has a null pattern.

◆ match() [1/2]

bool match ( const String text) const

Perform a pattern match against some text.

Parameters
textThe text.
Returns
true if the text matches the pattern, false otherwise.

◆ match() [2/2]

bool match ( const String text,
RegExpMatch  matches[],
int  numMatches 
) const

Perform a pattern match against some text, returning submatches.

Parameters
textThe text.
matchesThe objects in which the submatches will be recorded.
numMatchesThe number of submatches.
Returns
true if the text matches the pattern, false otherwise.

◆ operator!()

bool operator! ( ) const
inline

Determine if this regular expression has a null pattern.

◆ operator=()

RegExp & operator= ( const RegExp other)

Assignment operator.

◆ setPattern() [1/2]

void setPattern ( const char *  pattern,
bool  caseInsensitive = false 
)
inline

Set the regular expression pattern.

Parameters
patternThe pattern.
caseInsensitiveA flag indicating whether pattern matches using this pattern should be case-insensitive.
Exceptions
ParseExceptionIf the pattern is invalid.

◆ setPattern() [2/2]

void setPattern ( const String pattern,
bool  caseInsensitive = false 
)

Set the regular expression pattern.

Parameters
patternThe pattern.
caseInsensitiveA flag indicating whether pattern matches using this pattern should be case-insensitive.
Exceptions
ParseExceptionIf the pattern is invalid.

◆ toString()

String toString ( ) const
inline

Get a String representation of the RegExp.

Equivalent to getPattern().


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