Thursday 15 July 2010

Assistance With Lex/Flex Pattern -



Assistance With Lex/Flex Pattern -

the prof. c/c++ class has introduced flex (lexicographical analyzer), means total green-horn in utilize of flex.

the homework assignment working on remove html tags simple html file, leaving content. statement:

[^\/\n<>"]* printf("%s\n", yytext);

i able remove angle , quotation marks leaves behind tag text. added a-z within angle brackets , according 1 web tutorial placing quotation marks around angle brackets makes pattern:

[^\/\n"< a-za-z>""]* printf("%s\n", yytext);

all did remove letters leaving behind numbers punctuation, not after.

so how can tell flex include text between angle brackets along brackets create single regexp class out of it? little block of instruction preferred given answer. cool utility intend larn , use.

thanks in advance walt

well, html tags <something optional modifiers> (afaik), i'd rule set like

<[^>]*> { /* skip */ } . { printf("\%s", yytext); }

of course of study can speed processing if seek eat no html tag @ once. rule set above should work , easy understand.

lex

No comments:

Post a Comment