aboutsummaryrefslogtreecommitdiffstats
path: root/lispref
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>2004-09-28 15:23:44 +0000
committerRichard M. Stallman <[email protected]>2004-09-28 15:23:44 +0000
commit4d4d2d07a46f65709fe1727d477245b4b3649974 (patch)
treefbdb187a14dc99626b3ac141b2f6533ee18262fc /lispref
parent62ea61af7c3a8753dbdfaabab02b2ba4e17b98cc (diff)
(Regexp Search): Add looking-back.
Diffstat (limited to 'lispref')
-rw-r--r--lispref/searching.texi26
1 files changed, 26 insertions, 0 deletions
diff --git a/lispref/searching.texi b/lispref/searching.texi
index fd0d0e172a..93a152fbbe 100644
--- a/lispref/searching.texi
+++ b/lispref/searching.texi
@@ -975,6 +975,32 @@ comes back" twice.
@end example
@end defun
+@defun looking-back regexp &optional limit
+This function returns @code{t} if @var{regexp} matches text before
+point, ending at point, and @code{nil} otherwise.
+
+Because regular expression matching works only going forward, this is
+implemented by searching backwards from point for a match that ends at
+point. That can be quite slow if it has to search a long distance.
+You can bound the time required by specifying @var{limit}, which says
+not to search before @var{limit}. In this case, the match that is
+found must begin at or after @var{limit}.
+
+@example
+@group
+---------- Buffer: foo ----------
+I read "@point{}The cat in the hat
+comes back" twice.
+---------- Buffer: foo ----------
+
+(looking-back "read \"" 3)
+ @result{} t
+(looking-back "read \"" 4)
+ @result{} nil
+@end group
+@end example
+@end defun
+
@node POSIX Regexps
@section POSIX Regular Expression Searching