244 |
The next alternative is for @samp{a*} to match only two @samp{a}s. With |
The next alternative is for @samp{a*} to match only two @samp{a}s. With |
245 |
this choice, the rest of the regexp matches successfully.@refill |
this choice, the rest of the regexp matches successfully.@refill |
246 |
|
|
247 |
Nested repetition operators can be extremely slow if they specify |
Nested repetition operators can be extremely slow or loop infinitely |
248 |
backtracking loops. For example, it could take hours for the regular |
if they use repetition operators inside repetition operators. For |
249 |
expression @samp{\(x+y*\)*a} to try to match the sequence |
example, it could take hours for the regular expression |
250 |
@samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz}, before it ultimately fails. |
@samp{\(x+y*\)*a} to try to match the sequence |
251 |
The slowness is because Emacs must try each imaginable way of grouping |
@samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz}, before it ultimately |
252 |
the 35 @samp{x}s before concluding that none of them can work. To make |
fails. Emacs must try each way of grouping the 35 @samp{x}s before |
253 |
sure your regular expressions run fast, check nested repetitions |
concluding that none of them can work. Even worse, @samp{\(x*\)*} can |
254 |
|
match the null string in infinitely many ways, so it causes an |
255 |
|
infinite loop. To avoid these problems, check nested repetitions |
256 |
carefully. |
carefully. |
257 |
|
|
258 |
@item @samp{+} |
@item @samp{+} |