in reply to Re: parsing a very large array with regexps
in thread parsing a very large array with regexps
where each of the complete possibilities is written in one alternation. A more efficient way is to factor out what is common, so that you could write:/^(A|B|C|D|AB|BC|CD|ABC|BCD|ABCD)$/
Note that there are only four possible starting points, and if they don't occur, you don't have to look any further./^(A(B(CD?)?)?|B(CD?)?|CD?|D)$/
Similarly, in the example you gave, with 255 or more possible COMPLETE patterns to match, every one of them must start in only one of 9 possible ways, right? So you need to help the regexp engine by making the regexp more efficient, and that means factoring all the similar starting points into a single expression.
I am quite sure that this approach should work for your case.
|
|---|