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 or loop infinitely |
Nested repetition operators take a long time, or even forever, if they |
248 |
if they use repetition operators inside repetition operators. For |
lead to ambiguous matching. For example, trying to match the regular |
249 |
example, it could take hours for the regular expression |
expression @samp{\(x+y*\)*a} against the string |
250 |
@samp{\(x+y*\)*a} to try to match the sequence |
@samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz} could take hours before it |
251 |
@samp{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz}, before it ultimately |
ultimately fails. Emacs must try each way of grouping the 35 |
252 |
fails. Emacs must try each way of grouping the 35 @samp{x}s before |
@samp{x}s before concluding that none of them can work. Even worse, |
253 |
concluding that none of them can work. Even worse, @samp{\(x*\)*} can |
@samp{\(x*\)*} can match the null string in infinitely many ways, so |
254 |
match the null string in infinitely many ways, so it causes an |
it causes an infinite loop. To avoid these problems, check nested |
255 |
infinite loop. To avoid these problems, check nested repetitions |
repetitions carefully. |
|
carefully. |
|
256 |
|
|
257 |
@item @samp{+} |
@item @samp{+} |
258 |
@cindex @samp{+} in regexp |
@cindex @samp{+} in regexp |
346 |
|
|
347 |
@item @samp{[^ @dots{} ]} |
@item @samp{[^ @dots{} ]} |
348 |
@cindex @samp{^} in regexp |
@cindex @samp{^} in regexp |
349 |
@samp{[^} begins a @dfn{complemented character alternative}, which matches any |
@samp{[^} begins a @dfn{complemented character alternative}. This |
350 |
character except the ones specified. Thus, @samp{[^a-z0-9A-Z]} matches |
matches any character except the ones specified. Thus, |
351 |
all characters @emph{except} letters and digits. |
@samp{[^a-z0-9A-Z]} matches all characters @emph{except} letters and |
352 |
|
digits. |
353 |
|
|
354 |
@samp{^} is not special in a character alternative unless it is the first |
@samp{^} is not special in a character alternative unless it is the first |
355 |
character. The character following the @samp{^} is treated as if it |
character. The character following the @samp{^} is treated as if it |