mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-04 14:40:54 -08:00
Regexps cannot infloop; fix manual
* doc/lispref/searching.texi (Regexp Special): Edit erroneous
statements about infinite looping in regexps.
(cherry picked from commit 63268253d2)
This commit is contained in:
parent
cf0ee6f49b
commit
8ff5e346fe
1 changed files with 4 additions and 6 deletions
|
|
@ -338,16 +338,14 @@ first tries to match all three @samp{a}s; but the rest of the pattern is
|
|||
The next alternative is for @samp{a*} to match only two @samp{a}s. With
|
||||
this choice, the rest of the regexp matches successfully.
|
||||
|
||||
@strong{Warning:} Nested repetition operators can run for an
|
||||
indefinitely long time, if they lead to ambiguous matching. For
|
||||
@strong{Warning:} Nested repetition operators can run for a very
|
||||
long time, if they lead to ambiguous matching. For
|
||||
example, trying to match the regular expression @samp{\(x+y*\)*a}
|
||||
against the string @samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz} could
|
||||
take hours before it ultimately fails. Emacs must try each way of
|
||||
grouping the @samp{x}s before concluding that none of them can work.
|
||||
Even worse, @samp{\(x*\)*} can match the null string in infinitely
|
||||
many ways, so it causes an infinite loop. To avoid these problems,
|
||||
check nested repetitions carefully, to make sure that they do not
|
||||
cause combinatorial explosions in backtracking.
|
||||
In general, avoid expressions that can match the same string in
|
||||
multiple ways.
|
||||
|
||||
@item @samp{+}
|
||||
@cindex @samp{+} in regexp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue