From 3645358ade97894b3e355fdd37f3c9e73d5d62bb Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 21 Oct 2008 14:01:33 +0000 Subject: [PATCH] (Regexp Search): Document `string-match-p' and `looking-at-p'. (POSIX Regexps): Add an xref for "non-greedy". (Regexp Special): Add @cindex entry for "non-greedy". --- doc/lispref/ChangeLog | 5 +++++ doc/lispref/searching.texi | 19 ++++++++++++++++--- etc/NEWS | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 3308aa57db0..d3db94bc5fa 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,5 +1,10 @@ 2008-10-21 Eli Zaretskii + * searching.texi (Regexp Search): Document `string-match-p' and + `looking-at-p'. + (POSIX Regexps): Add an xref for "non-greedy". + (Regexp Special): Add @cindex entry for "non-greedy". + * display.texi (Attribute Functions): Document `face-all-attributes'. (Image Cache) : Minor wording fixes. diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index 36c3638b094..e5846028cfd 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi @@ -334,6 +334,7 @@ preceding expression either once or not at all. For example, @samp{ca?r} matches @samp{car} or @samp{cr}; nothing else. @item @samp{*?}, @samp{+?}, @samp{??} +@cindex non-greedy repetition characters in regexp These are ``non-greedy'' variants of the operators @samp{*}, @samp{+} and @samp{?}. Where those operators match the largest possible substring (consistent with matching the entire containing expression), @@ -1060,6 +1061,11 @@ the match is available as @code{(match-end 0)}. @xref{Match Data}. @end example @end defun +@defun string-match-p regexp string &optional start +This predicate function does what @code{string-match} does, but it has +no side effect of modifying the match data. +@end defun + @defun looking-at regexp This function determines whether the text in the current buffer directly following point matches the regular expression @var{regexp}. ``Directly @@ -1069,7 +1075,8 @@ result is @code{t} if so, @code{nil} otherwise. This function does not move point, but it updates the match data, which you can access using @code{match-beginning} and @code{match-end}. -@xref{Match Data}. +@xref{Match Data}. If you need to test for a match without modifying +the match data, use @code{looking-at-p}, described below. In this example, point is located directly before the @samp{T}. If it were anywhere else, the result would be @code{nil}. @@ -1113,6 +1120,11 @@ comes back" twice. @end example @end defun +@defun looking-at-p regexp +This predicate function works like @code{looking-at}, but without +updating the match data. +@end defun + @defvar search-spaces-regexp If this variable is non-@code{nil}, it should be a regular expression that says how to search for whitespace. In that case, any group of @@ -1142,8 +1154,9 @@ match, as required by POSIX. This is much slower, so use these functions only when you really need the longest match. The POSIX search and match functions do not properly support the -non-greedy repetition operators. This is because POSIX backtracking -conflicts with the semantics of non-greedy repetition. +non-greedy repetition operators (@pxref{Regexp Special, non-greedy}). +This is because POSIX backtracking conflicts with the semantics of +non-greedy repetition. @defun posix-search-forward regexp &optional limit noerror repeat This is like @code{re-search-forward} except that it performs the full diff --git a/etc/NEWS b/etc/NEWS index cf45b4fc38f..81dd4930601 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1618,6 +1618,7 @@ consing shell command lines from the individual arguments. *** `image-refresh' refreshes all images associated with a given image specification. ++++ *** The two new functions `looking-at-p' and `string-match-p' can do the same matching as `looking-at' and `string-match' without changing the match data. -- 2.39.5