diff options
| author | Richard M. Stallman | 2000-02-20 14:31:40 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2000-02-20 14:31:40 +0000 |
| commit | 2d06696fdcae3c266b917fb0a98bea9c01fa02fa (patch) | |
| tree | f4a8ec1a66e7a5aa3ecd0a84c87785c39fce9e85 /lispref | |
| parent | 65d0110b8559bf1c6dc734f2c376cbe6c384d223 (diff) | |
| download | emacs-2d06696fdcae3c266b917fb0a98bea9c01fa02fa.tar.gz emacs-2d06696fdcae3c266b917fb0a98bea9c01fa02fa.zip | |
*** empty log message ***
Diffstat (limited to 'lispref')
| -rw-r--r-- | lispref/searching.texi | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/lispref/searching.texi b/lispref/searching.texi index b38b6d95772..0b54fcd2fe8 100644 --- a/lispref/searching.texi +++ b/lispref/searching.texi | |||
| @@ -477,6 +477,25 @@ Full backtracking capability exists to handle multiple uses of | |||
| 477 | @samp{\|}, if you use the POSIX regular expression functions | 477 | @samp{\|}, if you use the POSIX regular expression functions |
| 478 | (@pxref{POSIX Regexps}). | 478 | (@pxref{POSIX Regexps}). |
| 479 | 479 | ||
| 480 | @item \@{@var{m}\@} | ||
| 481 | is a postfix operator that repeats the previous pattern exactly @var{m} | ||
| 482 | times. Thus, @samp{x\@{5\@}} matches the string @samp{xxxxx} | ||
| 483 | and nothing else. @samp{c[ad]\@{3\@}r} matches string such as | ||
| 484 | @samp{caaar}, @samp{cdddr}, @samp{cadar}, and so on. | ||
| 485 | |||
| 486 | @item \@{@var{m},@var{n}\@} | ||
| 487 | is more general postfix operator that specifies repetition with a | ||
| 488 | minimum of @var{m} repeats and a maximum of @var{n} repeats. If @var{m} | ||
| 489 | is omitted, the minimum is 0; if @var{n} is omitted, there is no | ||
| 490 | maximum. | ||
| 491 | |||
| 492 | For example, @samp{c[ad]\@{1,2\@}r} matches the strings @samp{car}, | ||
| 493 | @samp{cdr}, @samp{caar}, @samp{cadr}, @samp{cdar}, and @samp{cddr}, and | ||
| 494 | nothing else.@* | ||
| 495 | @samp{\@{0,1\@}} or @samp{\@{,1\@}} is equivalent to @samp{?}. @* | ||
| 496 | @samp{\@{0,\@}} or @samp{\@{,\@}} is equivalent to @samp{*}. @* | ||
| 497 | @samp{\@{1,\@}} is equivalent to @samp{+}. | ||
| 498 | |||
| 480 | @item \( @dots{} \) | 499 | @item \( @dots{} \) |
| 481 | @cindex @samp{(} in regexp | 500 | @cindex @samp{(} in regexp |
| 482 | @cindex @samp{)} in regexp | 501 | @cindex @samp{)} in regexp |
| @@ -496,14 +515,26 @@ To enclose a complicated expression for the postfix operators @samp{*}, | |||
| 496 | number (zero or more) of @samp{na} strings. | 515 | number (zero or more) of @samp{na} strings. |
| 497 | 516 | ||
| 498 | @item | 517 | @item |
| 499 | To record a matched substring for future reference. | 518 | To record a matched substring for future reference with |
| 519 | @samp{\@var{digit}} (see below). | ||
| 500 | @end enumerate | 520 | @end enumerate |
| 501 | 521 | ||
| 502 | This last application is not a consequence of the idea of a | 522 | This last application is not a consequence of the idea of a |
| 503 | parenthetical grouping; it is a separate feature that happens to be | 523 | parenthetical grouping; it is a separate feature that was assigned as a |
| 504 | assigned as a second meaning to the same @samp{\( @dots{} \)} construct | 524 | second meaning to the same @samp{\( @dots{} \)} construct because, in |
| 505 | because there is no conflict in practice between the two meanings. | 525 | pratice, there was usually no conflict between the two meanings. But |
| 506 | Here is an explanation of this feature: | 526 | occasionally there is a conflict, and that led to the introduction of |
| 527 | shy groups. | ||
| 528 | |||
| 529 | @item \(?: @dots{} \) | ||
| 530 | is the @dfn{shy group} construct. A shy group serves the first two | ||
| 531 | purposes of an ordinary group (controlling the nesting of other | ||
| 532 | operators), but it does not get a number, so you cannot refer back to | ||
| 533 | its value with @samp{\@var{digit}}. | ||
| 534 | |||
| 535 | Shy groups are particulary useful for mechanically-constructed regular | ||
| 536 | expressions because they can be added automatically without altering the | ||
| 537 | numbering of any ordinary, non-shy groups. | ||
| 507 | 538 | ||
| 508 | @item \@var{digit} | 539 | @item \@var{digit} |
| 509 | matches the same text that matched the @var{digit}th occurrence of a | 540 | matches the same text that matched the @var{digit}th occurrence of a |