Introduction

Syntax

Program Help

Examples

Download

Match Tool 2.1

Match Tool 3.0

 

DEELX Engine Examples: Test Digitals

To test whether a text contains digital numbers only.


Regular Expression

\d+


Method

MatchExact


Code
#include "deelx.h"

int test_all_number(const char * string)
{
    // declare, you can use 'static' if your regex does not change
    CRegexpT <char> regexp("\\d+");

    // test
    MatchResult result = regexp.MatchExact(string);

    // matched or not
    return result.IsMatched();
}

int main(int argc, char * argv[])
{
    char * str1 = "12345";
    char * str2 = "12345 abcde";

    printf("'%s' => %s\n", str1, (test_all_number(str1) ? "yes" : "no"));
    printf("'%s' => %s\n", str2, (test_all_number(str2) ? "yes" : "no"));

    return 0;
}

 

 

RegExLab.com © 2005 - All Rights Reserved