aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lispref/searching.texi16
1 files changed, 9 insertions, 7 deletions
diff --git a/lispref/searching.texi b/lispref/searching.texi
index 9e26363a43a..d18587ccecb 100644
--- a/lispref/searching.texi
+++ b/lispref/searching.texi
@@ -244,13 +244,15 @@ first tries to match all three @samp{a}s; but the rest of the pattern is
244The next alternative is for @samp{a*} to match only two @samp{a}s. With 244The next alternative is for @samp{a*} to match only two @samp{a}s. With
245this choice, the rest of the regexp matches successfully.@refill 245this choice, the rest of the regexp matches successfully.@refill
246 246
247Nested repetition operators can be extremely slow if they specify 247Nested repetition operators can be extremely slow or loop infinitely
248backtracking loops. For example, it could take hours for the regular 248if they use repetition operators inside repetition operators. For
249expression @samp{\(x+y*\)*a} to try to match the sequence 249example, it could take hours for the regular expression
250@samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz}, before it ultimately fails. 250@samp{\(x+y*\)*a} to try to match the sequence
251The slowness is because Emacs must try each imaginable way of grouping 251@samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz}, before it ultimately
252the 35 @samp{x}s before concluding that none of them can work. To make 252fails. Emacs must try each way of grouping the 35 @samp{x}s before
253sure your regular expressions run fast, check nested repetitions 253concluding that none of them can work. Even worse, @samp{\(x*\)*} can
254match the null string in infinitely many ways, so it causes an
255infinite loop. To avoid these problems, check nested repetitions
254carefully. 256carefully.
255 257
256@item @samp{+} 258@item @samp{+}