Java regexp: which is faster: a series of simple or a complex?

I'm writing a program that has to delete quite a lot of garbage I use regular expressions, and because my program is quite speed sensitive, I need to know which solution is faster: use multiple consecutive relatively simple regular expressions, or use a single but very complex expression?

Best wishes, Timothy

resolvent

Solution

You need to benchmark these things and ensure your results I doubt that a large regular expression will be faster than many small regular expressions, but I'd like to know what you found

java. util. regex. The pattern class is so complex that I don't pretend to know what optimizations it performs I know regular expressions are compiled into graphs, so it's obvious to combine overlapping paths The more changes you fill in a single expression, the more opportunities there are It can also reduce the number of input data transfers

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>