开发者

Java : does regex pattern matcher have a size limit?

开发者 https://www.devze.com 2023-03-13 08:14 出处:网络
My pattern is OR-like : \"word1|word2|word3\" I have approxima开发者_运维知识库tely 800 words.

My pattern is OR-like : "word1|word2|word3" I have approxima开发者_运维知识库tely 800 words.

Can it be a problem ?


You're only limited by memory and sanity. :)


You might consider using the Aho–Corasick string searching algorithm. It would be much more efficient than a regex, since it's linear and optimized for your problem. It's also a way to pay respect to our fellows from 1975 !

In particular, there is this Java implementation.


Why should it be? No, probably not.

A regexp with 800 words indicates a design problem somewhere, I would say. Why and what for do you need 800 words?

0

精彩评论

暂无评论...
验证码 换一张
取 消