Introduction

Syntax

Program Help

Examples

Download

Match Tool 2.1

Match Tool 3.0

 

DEELX Engine Examples: Match Continuously

To list each decimal fraction in a string.


Regular Expression

\b\d+\.\d+


Method

Match


Code Example 1
#include "deelx.h"

int main(int argc, char * argv[])
{
    // text
    char * text = "12.5, a1.1, 0.123, 178";

    // declare, you can use 'static' if your regex does not change
    CRegexpT <char> regexp("\\b\\d+\\.\\d+");

    // loop
    MatchResult result = regexp.Match(text);

    while( result.IsMatched() )
    {
        printf("%.*s\n", result.GetEnd() - result.GetStart(), text + result.GetStart());

        // get next
        result = regexp.Match(text, result.GetEnd());
    }

    return 0;
}
Code Example 2
#include "deelx.h"

int main(int argc, char * argv[])
{
    // text
    char * text = "12.5, a1.1, 0.123, 178";

    // declare, you can use 'static' if your regex does not change
    CRegexpT <char> regexp("\\b\\d+\\.\\d+");

    // prepare
    CContext * pContext = regexp.PrepareMatch(text);

    // loop
    MatchResult result = regexp.Match(pContext);

    while( result.IsMatched() )
    {
        printf("%.*s\n", result.GetEnd() - result.GetStart(), text + result.GetStart());

        // get next
        result = regexp.Match(pContext);
    }

    // release
    regexp.ReleaseContext(pContext);

    return 0;
}

 

 

RegExLab.com © 2005 - All Rights Reserved