diff lisp/subr.el @ 10560:fd09d51dfd77

(match-string): New function.
author Richard M. Stallman <rms@gnu.org>
date Fri, 27 Jan 1995 07:06:27 +0000
parents d74ab0c19706
children fa604ffe7e3f
line wrap: on
line diff
--- a/lisp/subr.el	Fri Jan 27 01:43:02 1995 +0000
+++ b/lisp/subr.el	Fri Jan 27 07:06:27 1995 +0000
@@ -882,6 +882,14 @@
            (cons 'progn body)
            (list 'store-match-data original)))))
 
+(defun match-string (n &optional string)
+  "Return the Nth subexpression matched by the last regexp search or match.
+If the last search or match was done against a string,
+specify that string as the second argument STRING."
+  (if string
+      (substring string (match-beginning 0) (match-end 0))
+    (buffer-substring string (match-beginning 0) (match-end 0))))
+
 (defun shell-quote-argument (argument)
   "Quote an argument for passing as argument to an inferior shell."
   ;; Quote everything except POSIX filename characters.