in reply to lookahead / lookbehind vs other regex methods
Avoiding capturing is one of the keys to writing quicker regexes. Using (?:...) rather than (...) when you don't need the capture can make a substantial difference to the speed at which they run, especially if the regex does a lot of backtracking; which is another thing to avoid where possible.
So using zero-length assertions instead of captures probably has the same benefits. It also makes the purpose of the regex less obscure IMO.
Note: This is just based my personal experiences of using the re, rather than any insight into the workings of the re.
|
|---|