/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <string.h>
#include <pcre.h>

void test(char *s)
{
    pcre *re;
    int rc;
    int erroffset;
    int ovector[300];
    const char *error;
    const char *p;
    re = pcre_compile("[0-9]+",0,&error,&erroffset,NULL);
    rc = pcre_exec(re,NULL,s,strlen(s),0,0,ovector,sizeof(ovector)/sizeof(int));
    if(rc < 0) 
    {
        printf("%s does NOT contain a number\n",s);
    }
    else
    {
        pcre_get_substring(s,ovector,rc,0,&p);
        printf("%s does contain a number and it is %s\n",s,p);
    }
}

int main()
{
    test("123");
    test("abc");
    test("123abc");
    return 0;
}
