有效地查询一个字符串中对多个正则表达式多个、有效地、字符串、中对

由网友(、可笑的敷衍)分享简介:比方说,我有10,000个正则表达式和一个字符串,我想看看字符串匹配任何人,并得到所有的比赛。在平凡的方式做到这一点是只查询字符串逐一对所有的正则表达式。是否有一个更快,更有效的方法来做到这一点? Lets say that I have 10,000 regexes and one string and I wa...

比方说,我有10,000个正则表达式和一个字符串,我想看看字符串匹配任何人,并得到所有的比赛。 在平凡的方式做到这一点是只查询字符串逐一对所有的正则表达式。是否有一个更快,更有效的方法来做到这一点?

Lets say that I have 10,000 regexes and one string and I want to find out if the string matches any of them and get all the matches. The trivial way to do it would be to just query the string one by one against all regexes. Is there a faster,more efficient way to do it?

编辑: 我曾尝试与DFA的(法),将其代 这里的问题是,它只会给你一个单一的模式。如果我有一个字符串hello和模式[H | H] ELLO和,DFA将只匹配其中之一,但我希望他们两个人打

I have tried substituting it with DFA's (lex) The problem here is that it would only give you one single pattern. If I have a string "hello" and patterns "[H|h]ello" and ".{0,20}ello", DFA will only match one of them, but I want both of them to hit.

推荐答案

马丁Sulzmann 做了在这个领域相当多的工作。 他有一个HackageDB项目解释breifly的

阅读全文

相关推荐

最新文章