All pastes #266606 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-12-04 07:37 UTC
rendered paste body
 vi test.c
[kans@localhost pcretest]$ gcc -c test.c
[kans@localhost pcretest]$ gcc -o pcret test.o -lpcre
[kans@localhost pcretest]$ ./pcret
Enter the details you wish to match:1#
No MatchEnter the details you wish to match:12345#
No MatchEnter the details you wish to match:78998#
No MatchEnter the details you wish to match:9#
No MatchEnter the details you wish to match:
[kans@localhost pcretest]$ vi test.c


-- Code below ----

#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <locale.h>
#include <errno.h>


#include <pcre.h>

int main(int argc,char *argv[])
{
     pcre *re;
     char cgets[250];
     const char *error;
     int erroffset;
     re = pcre_compile("(0-9)#",0,&error,&erroffset,NULL);
     if( re )
     {
     while(1){
     printf("Enter the details you wish to match:");
     fgets(cgets,250,stdin);
     if( pcre_exec(re,NULL,cgets,strlen(cgets),0,0,NULL,0) == 0 )
            printf("Matches");
     else
            printf("No Match");
     }
     } else  {
            printf("Error in Regex Compilation");
     }
}