<p><pre><code> /* ---
Made for use with http clients as described in https://news.ycombinator.com/item?id=17689165 and https://news.ycombinator.com/item?id=17689152
Assuming code below is saved as "030.l", one might compile program "yy030" with something like:
flex -8iCrfa 030.l
cc -pipe lex.yy.c -static -o yy030
--- */
#define p(x) fprintf(stdout,x,yytext);
#define jmp BEGIN
%s xa xb xc
int e,b,c;
xa "http://"|"https://"|"ftp://"
%%
/* non-printable */
\200|\201|\204|\223|\224|\230|\231|\234|\235
{xa} p("%s");jmp xa;
<xa>[^ \n\r<>"#'|)\]\}]* p("%s\n");jmp 0;
/* http:\/\/[^ \n\r<>"#'|]* fprintf(stdout,"%s\n",yytext); */
/* https:\/\/[^ \n\r<>"#'|]* fprintf(stdout,"%s\n",yytext); */
/* ftp:\/\/[^ \n\r<>"#'|]* fprintf(stdout,"%s\n",yytext); */
.|\n
%%
int main(){ yylex();}
int yywrap()
{
}</code></pre>
Uh, I cannot imagive why one would prefer this to a single “grep -o” invocation.<p>Not only “grep” command will be simpler to understand later, it will also be trivially customizeable/extendable