[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string-match and match-string
From: |
Bastien |
Subject: |
Re: string-match and match-string |
Date: |
Sat, 03 Nov 2007 13:02:05 +0000 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.0 (gnu/linux) |
"Lennart Borgman (gmail)" <address@hidden> writes:
> I get an error when doing things like these:
>
> (when (string-match "\\(some\\)" "<something>")
> (match-string 1))
>
> (when (string-match "<.*>" "<something>")
> (match-string 0))
>
> Should not match-string work here?
Use this instead:
(when (string-match "\\(some\\)" "<something>")
(match-string 1 "<something>"))
(when (string-match "<.*>" "<something>")
(match-string 0 "<something>"))
,----[ C-h f match-string ]
| match-string is a compiled Lisp function in `subr.el'.
| (match-string num &optional string)
|
| Return string of text matched by last search.
| num specifies which parenthesized expression in the last regexp.
| Value is nil if numth pair didn't match, or there were less than num pairs.
| Zero means the entire text matched by the whole regexp or whole string.
| string should be given if the last search was by `string-match' on string.
`----
The relevant part: "string should be given if the last search was by
`string-match' on string."
--
Bastien