]> git.eshelyaron.com Git - emacs.git/commitdiff
(match-string): New function.
authorRichard M. Stallman <rms@gnu.org>
Fri, 27 Jan 1995 07:06:27 +0000 (07:06 +0000)
committerRichard M. Stallman <rms@gnu.org>
Fri, 27 Jan 1995 07:06:27 +0000 (07:06 +0000)
lisp/subr.el

index a95f4d58efd0f54e0b3a04ecc79c7a4294ef1725..21438419302b1a88c2c3d7fc6b1e8b38a3c6fd7f 100644 (file)
@@ -882,6 +882,14 @@ Wildcards and redirection are handled as usual in the shell."
            (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.