diff options
| author | Richard M. Stallman | 2004-09-28 15:23:44 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2004-09-28 15:23:44 +0000 |
| commit | 4d4d2d07a46f65709fe1727d477245b4b3649974 (patch) | |
| tree | fbdb187a14dc99626b3ac141b2f6533ee18262fc | |
| parent | 62ea61af7c3a8753dbdfaabab02b2ba4e17b98cc (diff) | |
| download | emacs-4d4d2d07a46f65709fe1727d477245b4b3649974.tar.gz emacs-4d4d2d07a46f65709fe1727d477245b4b3649974.zip | |
(Regexp Search): Add looking-back.
| -rw-r--r-- | lispref/searching.texi | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lispref/searching.texi b/lispref/searching.texi index fd0d0e172a0..93a152fbbe1 100644 --- a/lispref/searching.texi +++ b/lispref/searching.texi | |||
| @@ -975,6 +975,32 @@ comes back" twice. | |||
| 975 | @end example | 975 | @end example |
| 976 | @end defun | 976 | @end defun |
| 977 | 977 | ||
| 978 | @defun looking-back regexp &optional limit | ||
| 979 | This function returns @code{t} if @var{regexp} matches text before | ||
| 980 | point, ending at point, and @code{nil} otherwise. | ||
| 981 | |||
| 982 | Because regular expression matching works only going forward, this is | ||
| 983 | implemented by searching backwards from point for a match that ends at | ||
| 984 | point. That can be quite slow if it has to search a long distance. | ||
| 985 | You can bound the time required by specifying @var{limit}, which says | ||
| 986 | not to search before @var{limit}. In this case, the match that is | ||
| 987 | found must begin at or after @var{limit}. | ||
| 988 | |||
| 989 | @example | ||
| 990 | @group | ||
| 991 | ---------- Buffer: foo ---------- | ||
| 992 | I read "@point{}The cat in the hat | ||
| 993 | comes back" twice. | ||
| 994 | ---------- Buffer: foo ---------- | ||
| 995 | |||
| 996 | (looking-back "read \"" 3) | ||
| 997 | @result{} t | ||
| 998 | (looking-back "read \"" 4) | ||
| 999 | @result{} nil | ||
| 1000 | @end group | ||
| 1001 | @end example | ||
| 1002 | @end defun | ||
| 1003 | |||
| 978 | @node POSIX Regexps | 1004 | @node POSIX Regexps |
| 979 | @section POSIX Regular Expression Searching | 1005 | @section POSIX Regular Expression Searching |
| 980 | 1006 | ||