TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Making single-purpose utilities example: filter URLs from input

1 pointsby textmodealmost 6 years ago
<p><pre><code> &#x2F;* --- Made for use with http clients as described in https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17689165 and https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17689152 Assuming code below is saved as &quot;030.l&quot;, one might compile program &quot;yy030&quot; with something like: flex -8iCrfa 030.l cc -pipe lex.yy.c -static -o yy030 --- *&#x2F; #define p(x) fprintf(stdout,x,yytext); #define jmp BEGIN %s xa xb xc int e,b,c; xa &quot;http:&#x2F;&#x2F;&quot;|&quot;https:&#x2F;&#x2F;&quot;|&quot;ftp:&#x2F;&#x2F;&quot; %% &#x2F;* non-printable *&#x2F; \200|\201|\204|\223|\224|\230|\231|\234|\235 {xa} p(&quot;%s&quot;);jmp xa; &lt;xa&gt;[^ \n\r&lt;&gt;&quot;#&#x27;|)\]\}]* p(&quot;%s\n&quot;);jmp 0; &#x2F;* http:\&#x2F;\&#x2F;[^ \n\r&lt;&gt;&quot;#&#x27;|]* fprintf(stdout,&quot;%s\n&quot;,yytext); *&#x2F; &#x2F;* https:\&#x2F;\&#x2F;[^ \n\r&lt;&gt;&quot;#&#x27;|]* fprintf(stdout,&quot;%s\n&quot;,yytext); *&#x2F; &#x2F;* ftp:\&#x2F;\&#x2F;[^ \n\r&lt;&gt;&quot;#&#x27;|]* fprintf(stdout,&quot;%s\n&quot;,yytext); *&#x2F; .|\n %% int main(){ yylex();} int yywrap() { }</code></pre>

1 comment

theamkalmost 6 years ago
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&#x2F;extendable
评论 #20121452 未加载