Unicorn XML Toolkit
Version 1.00.00

Namespace RegExp
Class CRegExp

class CRegExp: public CInterface {
public:
    CRegExp();
    ~CRegExp();
public:
    void Create(
        const CString &strPattern,
        bool bGlobal,
        bool bIgnoreCase,
        bool bMultiline);
    CString GetSource();
    bool GetGlobal();
    bool GetIgnoreCase();
    bool GetMultiline();
    int GetLastIndex();
    void SetLastIndex(int nLastIndex);
    bool Exec(const CString &strInput, CResult &result);
    bool Test(const CString &strInput);
    bool Match(
        const CString &strInput, 
        int nIndex,
        CResult &result);
    int Search(const CString &strInput);
    };

The ECMAScript regular expression.

Regular expressions are created from pattern strings. Each regular expression has global , ignoreCase , multiline , and lastIndex properties.

The value of the global property is a boolean which indicates whether a global match is required. This property corresponds to the property global of the ECMAScript RegExp instance.

The value of the ignoreCase property is a boolean which indicates whether characters in the input string must be canonicalized (treated case-insensitive). This property corresponds to the property ignoreCase of the ECMAScript RegExp instance.

The value of the multiline property is a boolean which indicates whether line separators in the input string require a special treatment. This property corresponds to the property multiline of the ECMAScript RegExp instance.

The value of the lastIndex property is an integer that specifies the string position at which to start the next match. This property corresponds to the property lastIndex of the ECMAScript RegExp instance.

See 15.10 RegExp (Regular Expression) Objects in ECMA-262, 3rd Edition for detailed description on how these properties affect the regular expression match algorithms.

Since:
1.00.00
Version:
1.00.00
Author:
Alexey Gokhberg
See Also:
CResult
Constructor/Destructor Summary
CRegExp ();
����������Constructs the regular expression.
~CRegExp ();
����������Destroys the regular expression.

Function Summary
void Create (const CString &strPattern, bool bGlobal, bool bIgnoreCase, bool bMultiline);
����������Creates the regular expression from the specified pattern string with specified boolean properties.
CString GetSource ();
����������Returns a pattern string of this regular expression.
bool GetGlobal ();
����������Returns a value of the global property of this regular expression.
bool GetIgnoreCase ();
����������Returns a value of the ignoreCase property of this regular expression.
bool GetMultiline ();
����������Returns a value of the multiline property of this regular expression.
int GetLastIndex ();
����������Returns a value of the lastIndex property of this regular expression.
void SetLastIndex (int nLastIndex);
����������Assigns a new value to the lastIndex property of this regular expression
bool Exec (const CString &strInput, CResult &result);
����������Executes this regular expression with the specified input string.
bool Test (const CString &strInput);
����������Tests the regular expression with the specified input string.
bool Match (const CString &strInput, int nIndex, CResult &result);
����������Invokes the matching algorithm associated with this regular expression pattern, passing the specified input string and the specified index as arguments of this algorithm.
int Search (const CString &strInput);
����������Searches from the beginning of the input string for a first occurence of this regular expression pattern.

Constructor/Destructor Detail

CRegExp

CRegExp();

Constructs the regular expression.

Content of this regular expression remains unspecified until the member function Create is called.

~CRegExp

~CRegExp();

Destroys the regular expression.

Function Detail

Create

void Create(
    const CString &strPattern,
    bool bGlobal,
    bool bIgnoreCase,
    bool bMultiline);

Creates the regular expression from the specified pattern string with specified boolean properties.

The pattern string must conform to the syntax of Pattern specified in "15.10.1 Patterns" of ECMA-262, 3rd Edition.

The lastIndex property is set to 0 .

Parameters:
strPattern - the pattern string
bGlobal - the value of the global property
bIgnoreCase - the value of the ignoreCase property
bMultiline - the value of the multiline property

GetSource

CString GetSource();

Returns a pattern string of this regular expression.

Returns:
the pattern string of this regular expression

GetGlobal

bool GetGlobal();

Returns a value of the global property of this regular expression.

Returns:
the value of the global property of this regular expression

GetIgnoreCase

bool GetIgnoreCase();

Returns a value of the ignoreCase property of this regular expression.

Returns:
the value of the ignoreCase property of this regular expression

GetMultiline

bool GetMultiline();

Returns a value of the multiline property of this regular expression.

Returns:
the value of the miltiline property of this regular expression

GetLastIndex

int GetLastIndex();

Returns a value of the lastIndex property of this regular expression.

Returns:
the value of the lastIndex property of this regular expression

SetLastIndex

void SetLastIndex(int nLastIndex);

Assigns a new value to the lastIndex property of this regular expression

Parameters:
nLastIndex - the new value of the lastIndex property

Exec

bool Exec(const CString &strInput, CResult &result);

Executes this regular expression with the specified input string.

This function has the semantics similar to that of exec function property of the RegExp prototype specified by ECMA-262.

Parameters:
strInput - the input string
result - on return, the array of captures, if the match was successful; unspecified if the match failed
Returns:
true if the match was successful; false if the match failed

Test

bool Test(const CString &strInput);

Tests the regular expression with the specified input string.

This function has the semantics similar to that of test function property of the RegExp prototype specified by ECMA-262.

Parameters:
strInput - the input string
Returns:
true if the test was successful, false if the test failed

Match

bool Match(
    const CString &strInput, 
    int nIndex,
    CResult &result);

Invokes the matching algorithm associated with this regular expression pattern, passing the specified input string and the specified index as arguments of this algorithm.

The matching algorithm is described in 15.10.2.2 Pattern of ECMA-262, 3rd Edition; parameters strInput and nIndex correspond to str and index arguments of an internal closure obtained as the result of evaluation of the production Pattern::Disjunction.

Parameters:
strInput - the input string
nIndex - the index
result - on return, the array of captures, if the match was successful; unspecified if the match failed
Returns:
true if the match was successful; false if the match failed

Search

int Search(const CString &strInput);

Searches from the beginning of the input string for a first occurence of this regular expression pattern.

This function ignores global and lastIndex properties of the regular expression. The lastIndex property is left unchanged.

This function has the semantics similar to that of search function property of the String prototype specified by ECMA-262.

Parameters:
strInput - the input string
Returns:
the offset within the string where the pattern matched; -1 if there was no match

Unicorn XML Toolkit
Version 1.00.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.