aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2004-09-28 15:23:44 +0000
committerRichard M. Stallman2004-09-28 15:23:44 +0000
commit4d4d2d07a46f65709fe1727d477245b4b3649974 (patch)
treefbdb187a14dc99626b3ac141b2f6533ee18262fc
parent62ea61af7c3a8753dbdfaabab02b2ba4e17b98cc (diff)
downloademacs-4d4d2d07a46f65709fe1727d477245b4b3649974.tar.gz
emacs-4d4d2d07a46f65709fe1727d477245b4b3649974.zip
(Regexp Search): Add looking-back.
-rw-r--r--lispref/searching.texi26
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
979This function returns @code{t} if @var{regexp} matches text before
980point, ending at point, and @code{nil} otherwise.
981
982Because regular expression matching works only going forward, this is
983implemented by searching backwards from point for a match that ends at
984point. That can be quite slow if it has to search a long distance.
985You can bound the time required by specifying @var{limit}, which says
986not to search before @var{limit}. In this case, the match that is
987found must begin at or after @var{limit}.
988
989@example
990@group
991---------- Buffer: foo ----------
992I read "@point{}The cat in the hat
993comes 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