Mercurial > emacs
comparison lispref/searching.texi @ 90813:e6fdae9180d4
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 698-710)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 216)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-196
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 24 Apr 2007 21:56:25 +0000 |
parents | 4ef881a120fe 4d7a5d9bbe76 |
children | 3619e7770f2e |
comparison
equal
deleted
inserted
replaced
90812:6137cc8ddf90 | 90813:e6fdae9180d4 |
---|---|
307 first tries to match all three @samp{a}s; but the rest of the pattern is | 307 first tries to match all three @samp{a}s; but the rest of the pattern is |
308 @samp{ar} and there is only @samp{r} left to match, so this try fails. | 308 @samp{ar} and there is only @samp{r} left to match, so this try fails. |
309 The next alternative is for @samp{a*} to match only two @samp{a}s. With | 309 The next alternative is for @samp{a*} to match only two @samp{a}s. With |
310 this choice, the rest of the regexp matches successfully. | 310 this choice, the rest of the regexp matches successfully. |
311 | 311 |
312 @strong{Warning:} Nested repetition operators take a long time, | 312 @strong{Warning:} Nested repetition operators can run for an |
313 or even forever, if they | 313 indefinitely long time, if they lead to ambiguous matching. For |
314 lead to ambiguous matching. For example, trying to match the regular | 314 example, trying to match the regular expression @samp{\(x+y*\)*a} |
315 expression @samp{\(x+y*\)*a} against the string | 315 against the string @samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz} could |
316 @samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz} could take hours before it | 316 take hours before it ultimately fails. Emacs must try each way of |
317 ultimately fails. Emacs must try each way of grouping the 35 | 317 grouping the @samp{x}s before concluding that none of them can work. |
318 @samp{x}s before concluding that none of them can work. Even worse, | 318 Even worse, @samp{\(x*\)*} can match the null string in infinitely |
319 @samp{\(x*\)*} can match the null string in infinitely many ways, so | 319 many ways, so it causes an infinite loop. To avoid these problems, |
320 it causes an infinite loop. To avoid these problems, check nested | 320 check nested repetitions carefully, to make sure that they do not |
321 repetitions carefully, to make sure that they do not cause combinatorial | 321 cause combinatorial explosions in backtracking. |
322 explosions in backtracking. | |
323 | 322 |
324 @item @samp{+} | 323 @item @samp{+} |
325 @cindex @samp{+} in regexp | 324 @cindex @samp{+} in regexp |
326 is a postfix operator, similar to @samp{*} except that it must match | 325 is a postfix operator, similar to @samp{*} except that it must match |
327 the preceding expression at least once. So, for example, @samp{ca+r} | 326 the preceding expression at least once. So, for example, @samp{ca+r} |