Rudiments
Public Member Functions | Static Public Member Functions | List of all members
regularexpression Class Reference

#include <regularexpression.h>

Inherits object.

Public Member Functions

 regularexpression ()
 
 regularexpression (const char *pattern)
 
 ~regularexpression ()
 
bool setPattern (const char *pattern)
 
const chargetPattern ()
 
bool study ()
 
bool match (const char *str)
 
bool match (const char *str, size_t length)
 
int32_t getSubstringCount ()
 
const chargetSubstringStart (int32_t index)
 
const chargetSubstringEnd (int32_t index)
 
int32_t getSubstringStartOffset (int32_t index)
 
int32_t getSubstringEndOffset (int32_t index)
 
- Public Member Functions inherited from object
virtual ~object ()
 

Static Public Member Functions

static bool match (const char *str, size_t length, const char *pattern)
 
static bool match (const char *str, const char *pattern)
 

Detailed Description

The regularexpression class provides methods for making comparisons between text and regular expressions.

Regular expressions are complex, powerful, used in command line programs like grep, sed and find, and extensively in Perl.

Constructor & Destructor Documentation

◆ regularexpression() [1/2]

regularexpression::regularexpression ( )

Creates an instance of the regularexpression class.

◆ regularexpression() [2/2]

regularexpression::regularexpression ( const char * pattern)

Creates an instance of the regularexpression class and sets the regular expression of this instance to "pattern".

◆ ~regularexpression()

regularexpression::~regularexpression ( )

Deletes this instance of the regular expression class.

Member Function Documentation

◆ getPattern()

const char * regularexpression::getPattern ( )

Returns the regular expression of this instance.

◆ getSubstringCount()

int32_t regularexpression::getSubstringCount ( )

Returns the number of substrings of "str" passed into match() that match "pattern" passed into compile().

◆ getSubstringEnd()

const char * regularexpression::getSubstringEnd ( int32_t index)

Returns the data directly after the "index"'th matching substring or NULL if index is invalid.

◆ getSubstringEndOffset()

int32_t regularexpression::getSubstringEndOffset ( int32_t index)

Returns the offset of the data directly after the "index"'th matching substring or -1 if index is invalid.

◆ getSubstringStart()

const char * regularexpression::getSubstringStart ( int32_t index)

Returns the "index"'th matching substring or NULL if index is invalid.

◆ getSubstringStartOffset()

int32_t regularexpression::getSubstringStartOffset ( int32_t index)

Returns the offset of the "index"'th matching substring or -1 if index is invalid.

◆ match() [1/4]

bool regularexpression::match ( const char * str)

Matches "str" against the regular expression compiled earlier using the compile method.

Returns true if the match was successful and false if it was not.

◆ match() [2/4]

static bool regularexpression::match ( const char * str,
const char * pattern )
static

Returns true if "str" matches "pattern" and false otherwise.

◆ match() [3/4]

bool regularexpression::match ( const char * str,
size_t length )

Matches the first "length" character of "str" against the regular expression compiled earlier using the compile method.

Returns true if the match was successful and false if it was not.

◆ match() [4/4]

static bool regularexpression::match ( const char * str,
size_t length,
const char * pattern )
static

Returns true if the first "length" characters of "str" matches "pattern" and false otherwise.

◆ setPattern()

bool regularexpression::setPattern ( const char * pattern)

Sets the regular expression of this instance to "pattern".

Returns true if the compilation succeeded and false if it failed.

◆ study()

bool regularexpression::study ( )

Studies the current pattern so it can be executed faster. If you plan on calling match() several times on this pattern, studying it may be worthwhile. If not, the studying the pattern may take longer than the time saved by studying it.

Returns true if the study succeeded and false if if failed.