Use lazy quantifiers strategically instead of greedy quantifiers that cause excessive backtracking

Suppose we need to match an input that contains three complete words, start, middle, and end, separated by non-whitespace characters.

Consider using the following pattern with a lazy quantifier:

startS+?middleS+?end 

Instead of using the following pattern, our match will be faster if we use the preceding pattern:

startS+middleS+end 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.10