Sublime Forum

Large file RegEx crash

#1

I have a few files that are around 16 MB and 69k lines long.

I’m going through and deleting particular lines from the files with a RegEx:

(^.*string1.*$|^.*string2.*$|^.*string3.*$|^.*string4.*$|^.*string5.*$)

It seems ok handling 3 strings, but 4 and 5 crash even on one file with the error:

The complexity of matching the regular expression exceeded predefined bounds. Try refactoring the regular expression to make each choice made by the state machine unambiguous. This exception is thrown to prevent "eternal" matches that take an indefinite

Why is this happening? Is there a workaround for the time being? I’m on ST3 Stable 3126.

1 Like

#2

If you change it to

^.*(?:string1|string2|string3|string4|string5).*$

it should to the same and be faster (you can wrap it in parens if you want it as a group).

1 Like

#3

Thank you! Huge speed boost, too.

0 Likes