Introduction

Syntax

Program Help

Examples

Download

Match Tool 2.1

Match Tool 3.0

 

CRegexpT Template Class

Return: Content | Next: constructor


Summary

CRegexpT template class is the most important class in DEELX. It takes charge of matching and replacing.

CRegexpT object records only information of compiled regular expression. All matching and replacing methods do not modifity CRegexpT object. So, these methods are thread safe.

CRegexpT can be used to any simple types:

template <class CHART> class CRegexpT;

Members

constructor
     To construct a CRegexpT object. If parameter added, it will call compile.

Compile
     To compile a regular expression. CRegexpT can be valid only after compiled.

MatchExact
     To test if the regular expression can match from beginning just to the end.

Match
     To search and match in a text.

GetNamedGroupNumber
     Get group number from group name.

PrepareMatch
     Create a context object which is used to match many times continuously.

Replace
     To replace matched substrings to other strings.

ReleaseContext
     To release a context object which is returned by PrepareMatch method.

ReleaseString
     To release a string which is returned by Replace method.


Class Definition
template <class CHART> class CRegexpT
{
public:
    CRegexpT(
        const CHART * pattern = 0,
        int flags = 0);

    void Compile(
        const CHART * pattern,
        int flags = 0);

public:
    MatchResult MatchExact(
        const CHART * tstring) const;

    MatchResult Match(
        const CHART * tstring,
        int start = -1) const;

    MatchResult Match(
        CContext * pContext) const;

    CContext * PrepareMatch(
        const CHART * tstring,
        int start = -1) const;

    CHART * Replace(
        const CHART * tstring,
        const CHART * replaceto,
        int start = -1,
        int ntimes = -1) const;

    int GetNamedGroupNumber(
        const CHART * group_name) const;

public:
    static void ReleaseString(
        CHART * tstring );

    static void ReleaseContext(
        CContext * pContext);
};

 

 

RegExLab.com © 2005 - All Rights Reserved