changeset 10560:fd09d51dfd77

(match-string): New function.
author Richard M. Stallman <rms@gnu.org>
date Fri, 27 Jan 1995 07:06:27 +0000
parents dcb43c6d4c42
children 53f34c870201
files lisp/subr.el
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
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.