From: Richard M. Stallman Date: Thu, 21 Mar 2002 09:37:22 +0000 (+0000) Subject: Clarify non-greedy repetition in searching. X-Git-Tag: ttn-vms-21-2-B4~16048 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bed0fc913cfff3f02eba6c7ee5e2fe144f3f1465;p=emacs.git Clarify non-greedy repetition in searching. --- diff --git a/man/search.texi b/man/search.texi index 36ed3747154..1739f93bc8d 100644 --- a/man/search.texi +++ b/man/search.texi @@ -463,6 +463,13 @@ the text @samp{abbb}, @samp{ab*} will match it all (the longest valid match), while @samp{ab*?} will match just @samp{a} (the shortest valid match). +Non-greedy operators match the shortest possible string starting at a +given starting point; in a forward search, though, the earliest +possible starting point for match is always the one chosen. Thus, if +you search for @samp{a.*?$} against the text @samp{abbab} followed by +a newline, it matches the whole string. Since it @emph{can} match +starting at the first @samp{a}, it does. + @item \@{@var{n}\@} is a postfix operator that specifies repetition @var{n} times---that is, the preceding regular expression must match exactly @var{n} times