On Wed, Mar 15, 2017 at 4:26 PM, Stefan Monnier wrote: > because "[\s\t]+$" shouldn't backtrack. Using "\\s-+$" with > a syntax-table that puts \n in the whitespace syntax is indeed asking > for trouble, but I'm surprised "[\s\t]+$" is only twice as fast as this > pathological case (and hence presumably much slower than "\\s-+$" when > \n is not whitespace). Why should one backtrack and not the other? The *2 ratio seems to hold for both pathologically slow and normal case. Matching against a sequence of non-trailing whitespace seens to have quadradic complexity (see attached, timings are from an elisp buffer), does that give you any hints?