Regular expressions, C++ kai linux
V13
v13 at priest.com
Tue Jun 25 17:06:02 EEST 2002
On Tuesday 25 June 2002 15:07, Dimitris Stasinopoulos wrote:
[...]
Steile an mporeis kati poy na kanei compile kai na coriazei...
Epimeno oti to lathos einai kapoy alloy, eidika meta apo ta ypoloipa poy
anafereis. To parakato, den moy coriase..
#include <sys/types.h>
#include <regex.h>
#include <stdlib.h>
#include <stdio.h>
char * cc_strstr_nocase(char * haystack, char * needle)
{
regex_t preg;
regmatch_t pmatch;
int err_no=0;
int offset=0;
if(haystack==NULL)
return NULL;
if(needle==NULL)
return haystack;
err_no=regcomp(&preg, needle, REG_ICASE);
if(err_no)
return NULL;
err_no=regexec(&preg, haystack, 1, &pmatch, 0);
if(err_no)
{
regfree(&preg);
return NULL;
}
offset=pmatch.rm_so;
regfree(&preg);
return haystack+offset;
}
int main()
{
char *a="loAbc";
char *b="a";
char *d;
d=cc_strstr_nocase(a,b);
printf("%s %s %s\n",a,b,d);
}
<<V13>>
More information about the Linux-greek-users
mailing list