Ok,
I have been recently trying to do a pattern matching with regular expressions.I have to do this in C(No other language) .I have used slre library and wrote this:
This works fine for short string.But my problem is that I will have to check for this pattern in a whole web page source code about 60000 characters but unfortunately slre is not able to handle it for some reason.Whenever I use this code in that program to look for this pattern in webpage,It never ends.There is No Loops.The program doesn't terminate.And with smaller strings it is ok.But slow.
So I wanted to use PCRE.But I am not getting it how to use it.I tried downloading the library but pcre.h is not there.Can somebody show me how to use PCRE like this code.Starting from the download.Please I really need it.Or show me some other effective way to handle huge strings and matching patters please.
Best Regards.
I have been recently trying to do a pattern matching with regular expressions.I have to do this in C(No other language) .I have used slre library and wrote this:
Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "slre.h"
#include "slre.c"
int main(void)
{
char* mystring = "potty <body class=\"admin-yokohoma admin-235\"> lovely baby :*";
struct slre_cap caps[2];
static const char* regex = "<body class=\".*(admin-).*(admin-).*\">";
if(slre_match(regex,mystring, strlen(mystring), caps, 2, 1) > 0)
{
char buffer[100];
printf("We have found it! Yay!\n");
char* ptr = caps[0].ptr + 6;
char* loc = strchr(ptr ,' ');
int ttlsize = (int) (loc - ptr);
printf("%d\n",ttlsize);
strncpy(buffer,ptr,ttlsize);
buffer[ttlsize] = '\0';
printf("Matched:%s",buffer);
}
}This works fine for short string.But my problem is that I will have to check for this pattern in a whole web page source code about 60000 characters but unfortunately slre is not able to handle it for some reason.Whenever I use this code in that program to look for this pattern in webpage,It never ends.There is No Loops.The program doesn't terminate.And with smaller strings it is ok.But slow.
So I wanted to use PCRE.But I am not getting it how to use it.I tried downloading the library but pcre.h is not there.Can somebody show me how to use PCRE like this code.Starting from the download.Please I really need it.Or show me some other effective way to handle huge strings and matching patters please.
Best Regards.

