match-string

(setq test/search "abcda");;C-j
"abcda"


(string-match "a\\(\\w+\\)a" test/search);;C-j
0

(match-string 0 test/search);;C-j
"cda"

(match-string 1 test/search);;C-j
"a"

这里有两个不懂的

  1. 为啥(前面要加两个\,\w前面加一个\说的过去,括号也是特殊字符吗
  2. 这个match-string 得到的为啥是cdaa,不应该是abcdabcd吗?

建议自己重新运行一下,这是我得到的结果

(setq test/search "abcda")
"abcda"
(string-match "a\\(\\w+\\)a" test/search)
0
(match-string 0 test/search)
"abcda"
(match-string 1 test/search)
"bcd"

image

奇怪。不过看到你正常,我心里就有数了