Re: c regex example



On Jul 21, 8:39 pm, gert <gert.cuyk...@xxxxxxxxx> wrote:
On Jul 21, 9:21 am, Ico <use...@xxxxxxx> wrote:

Save the return value of regcomp() and use regerror() to convert the
error code into a readable string when not zero

Ok that i did and figured out the regex was invalid aldo it isn't some
how it doesn't understand (?

also memcpy is not copying what i expect and it gets stuck in a
infinitive loop also :)

http://dfo.svn.sourceforge.net/viewvc/dfo/trunk/cgi/csv.c?view=markup

void
csv(char *buffer,PAGE *page)
{
char *line;
char errbuf[100];
int errcode;
regex_t re;
regmatch_t rm;
errcode=regcomp(&re,"test", REG_EXTENDED);
//csv regex ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))"
//csv regex ,(?=(?:[^ "]* "[^ "]* ")*(?![^ "]* "))
if(errcode==0)errcode=regexec(&re, &buffer[0], 1, &rm, 0);
while(errcode==0)
{
memcpy(line, &buffer[rm.rm_so], rm.rm_eo-rm.rm_so);
page->add(page,line);
errcode=regexec(&re, &buffer[rm.rm_eo], 1, &rm, 0);
}
regerror(errcode,&re,errbuf,100);
if(errbuf)printf("%s\n",errbuf);
regfree(&re);

}

Doh the memcpy doesnt work because i forgot to alocate memory first,
still need a answer for infinitive loop and the csv regex that is
invalid :)

.



Relevant Pages

  • Re: c regex example
    ... error code into a readable string when not zero ... Ok that i did and figured out the regex was invalid aldo it isn't some ... char errbuf; ...
    (comp.programming)
  • Re: Are Regex slower than methods from classes like String & Char?
    ... I wonder if regular expressions are in general sower than using ... String and Char. ... Maybe Regex are slower only when matching is relatively simple? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Are Regex slower than methods from classes like String & Char?
    ... String and Char. ... Maybe Regex are slower only when matching is relatively simple? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regex - Ensure 0,1 occurrences from a list of possibilities
    ... which is that even if one can come up with a regex ... bool IsValid(string strInput, string strStart, char[] rgchValid) ... Performance-wise, for short "valid character" arrays it should be ... For people who do understand regex, it's an easy to read solution (if you haven't written any C# in your life functions like these can become just as ugly... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regex failed to replace utf8 character
    ... search engine cache. ... I'm reading in the file line by line and applying ... the following regex: ... # Char that I copied and pasted directly from the HTML file ...
    (comp.lang.perl.misc)