Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Linux 系统上哪个模式匹配效率更高?
贝尔实验室的 Russ Cox 在 2007 年写了一篇很棒的文章。在这篇文章中,他展示了如何grep使用 非确定性有限自动机来提高 Perl 和其他软件的速度。
grep
正则表达式匹配可以简单快速
我找到了最适合我的方法。
在我拥有一个包含数千个元素的数组之前,我使用了另一个包含数千个元素的列表来从数组中获取更多信息。
现在我将一次我的数组放入哈希数组,然后每次都非常快速地从中获取数据。
曾是:
@ua1 = grep /$ip/, @ua;
现在:
$ua1[0] = $adrs{$ip};