changeset 11651:f43818d3bbd8

Warn about nested repetition.
author Richard M. Stallman <rms@gnu.org>
date Tue, 02 May 1995 03:47:29 +0000
parents 38f3ac2845f7
children 1162093d885c
files lispref/searching.texi
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lispref/searching.texi	Tue May 02 02:18:34 1995 +0000
+++ b/lispref/searching.texi	Tue May 02 03:47:29 1995 +0000
@@ -225,6 +225,14 @@
 The next alternative is for @samp{a*} to match only two @samp{a}s.
 With this choice, the rest of the regexp matches successfully.@refill
 
+Nested repetition operators can be extremely slow if they specify
+backtracking loops.  For example, @samp{\(x+y*\)*a} could take hours to
+match the sequence @samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz}.  The
+slowness is because Emacs must try each imaginable way of grouping the
+35 @samp{x}'s before concluding that none of them can work.  To make
+sure your regular expressions run fast, check nested repetitions
+carefully.
+
 @item +
 @cindex @samp{+} in regexp
 is a suffix operator similar to @samp{*} except that the preceding