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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: List of words – List of regexes tool?

4 点作者 e7mac超过 10 年前
Does anyone know of a tool that would input a list of strings and output a list of regexes that match the strings? An intelligent regex pattern matcher ? If not, what do you think about building something like this?

2 条评论

_jomo超过 10 年前
There is this insane email validating RegEx [0]. The page says:<p>&gt; I did not write this regular expression by hand. It is generated by the Perl module by concatenating a simpler set of regular expressions that relate directly to the grammar defined in the RFC.<p>There&#x27;s also the famous xkcd Regex Golf [1]. Peter Norvig writes:<p>&gt;So that got me thinking: can I come up with an algorithm to find a short regex that matches the winners and not the losers?<p>And he described his steps to create a RegEx using a list of words that must be matched and those that must not be matched [2]<p>[0]: <a href="http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html" rel="nofollow">http:&#x2F;&#x2F;www.ex-parrot.com&#x2F;~pdw&#x2F;Mail-RFC822-Address.html</a><p>[1]: <a href="https://xkcd.com/1313/" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;1313&#x2F;</a><p>[2]: <a href="http://nbviewer.ipython.org/url/norvig.com/ipython/xkcd1313.ipynb" rel="nofollow">http:&#x2F;&#x2F;nbviewer.ipython.org&#x2F;url&#x2F;norvig.com&#x2F;ipython&#x2F;xkcd1313....</a>
评论 #8779989 未加载
alansammarone超过 10 年前
Well, this is somewhat vague. There&#x27;s more than one way of matching any string - you&#x27;d have to be more specific about what exact form you want your regexes to have.
评论 #8779710 未加载