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