在程序中而不是在交互模式下使用 `replace-regexp`
Use `replace-regexp` in program rather in interative mdoe
我试过了
ELISP> (replace-regexp "war" "negotiation" "trade war")
nil
ELISP>
我期望的结果是"trade negotiation"
如何在 elisp 程序中使用正则表达式?
我认为您错误地使用了 replace-regex 而不是 replace-regexp-in-string:
ELISP> (replace-regexp-in-string "war" "negotiation" "trade war")
"trade negotiation"
replace-regexp 的第三个参数是:
Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
only matches surrounded by word boundaries. A negative prefix arg means
replace backward.
我试过了
ELISP> (replace-regexp "war" "negotiation" "trade war")
nil
ELISP>
我期望的结果是"trade negotiation"
如何在 elisp 程序中使用正则表达式?
我认为您错误地使用了 replace-regex 而不是 replace-regexp-in-string:
ELISP> (replace-regexp-in-string "war" "negotiation" "trade war")
"trade negotiation"
replace-regexp 的第三个参数是:
Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace only matches surrounded by word boundaries. A negative prefix arg means replace backward.