c regex example
- From: gert <gert.cuykens@xxxxxxxxx>
- Date: Sat, 21 Jul 2007 00:50:46 -0000
Can anybody tell whats wrong ?
#include <stdio.h>
#include <string.h>
#include <regex.h>
void
csv(char *buffer)
{
char *line;
char *errbuf;
size_t errbuf_size;
int errcode;
regex_t re;
regmatch_t rm;
regcomp (&re, ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))",
REG_EXTENDED);
errcode=regexec(&re, &buffer[0], 1, &rm, 0);
while(errcode==0)
{
strncpy (line, buffer+rm.rm_so, rm.rm_eo-rm.rm_so);
printf("%s\n",line);
errcode=regexec (&re, buffer+rm.rm_eo, 1, &rm, 0);
}
regerror(errcode,&re,errbuf,errbuf_size);
printf("%s\n",errbuf);
regfree(&re);
}
int
main(void)
{
csv("test,test");
}
.
- Follow-Ups:
- Re: c regex example
- From: gert
- Re: c regex example
- From: Ico
- Re: c regex example
- Prev by Date: Re: Multi core vs. single core application issues
- Next by Date: Re: c regex example
- Previous by thread: Multi core vs. single core application issues
- Next by thread: Re: c regex example
- Index(es):
Relevant Pages
|