summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-01-27 07:06:27 +0000
committerRichard M. Stallman <rms@gnu.org>1995-01-27 07:06:27 +0000
commitab591aaebd91e6f50b1f05b8e84cf693f904dafd (patch)
treee6da06f4841c1ac197e56ffa252855ce5fd377e2 /lisp/subr.el
parent2d0933b480e0c470c5f2752a981d2052444f1858 (diff)
downloademacs-ab591aaebd91e6f50b1f05b8e84cf693f904dafd.tar.gz
(match-string): New function.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index a95f4d58efd..21438419302 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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.