TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A Regular Expression Matcher (2007)

109 点作者 ville超过 5 年前

7 条评论

dang超过 5 年前
A thread from 2016: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12199836" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12199836</a><p>2013: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5672875" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5672875</a><p>2011: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=2723366" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=2723366</a><p>Maybe others?<p>p.s. these links are just for curious readers; reposts are ok after a year or so—see <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;newsfaq.html" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;newsfaq.html</a>.
adriantam超过 5 年前
This is chapter 1 of &quot;Beautiful Code&quot; (<a href="http:&#x2F;&#x2F;shop.oreilly.com&#x2F;product&#x2F;9780596510046.do" rel="nofollow">http:&#x2F;&#x2F;shop.oreilly.com&#x2F;product&#x2F;9780596510046.do</a>)
评论 #22319280 未加载
glangdale超过 5 年前
These posts are great for history, but regular expression implementation has moved on considerably from early Thompson implementations whether backtracking or NFAs. There is a considerable body of literature about regex implementation, including many quite convincing implementations and alternate formulations, some of which weren&#x27;t even done by people at, or from, Bell Labs!<p>We seem to have something of an Eternal September of regex implementation knowledge (abetted by Russ Cox&#x27;s amazingly selective bibliography in his posts introducing RE2).
hstaab超过 5 年前
I saw this in the repo of single file language implementations that was posted yesterday. Glad to see it on the front page now.<p>Here’s the repo if anyone is interested in checking out the others:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;marcpaq&#x2F;b1fipl" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;marcpaq&#x2F;b1fipl</a>
jstimpfle超过 5 年前
Skimming over it, the implementation looks inefficient:<p><pre><code> int matchstar(int c, char *regexp, char *text) { do { &#x2F;* a * matches zero or more instances *&#x2F; if (matchhere(regexp, text)) return 1; } while (*text != &#x27;\0&#x27; &amp;&amp; (*text++ == c || c == &#x27;.&#x27;)); return 0; } </code></pre> That can be used to match short strings, but not to grep through a filesystem. A good regex matcher has runtime O(N*M) where N is the length of the regex (typically very short) and M is the length of the scanned text.
评论 #22322292 未加载
评论 #22326168 未加载
raverbashing超过 5 年前
Seeing code like this I can understand why the pioneers though C code could be pretty.<p>But now all I see there is something more akin to a demonstration of ice carving with chainsaws than something that should be used in a production system.
leoh超过 5 年前
This would be a very good technical interview question — i.e. &quot;implement this simple regex specification.&quot;
评论 #22319670 未加载
评论 #22320963 未加载
评论 #22321566 未加载
评论 #22319332 未加载