![](/img/trans.png)
[英]Emacs, using replace-regexp-in-string to match two regexps
[英]Beginning and end of the string in Emacs regexps
哪些字符表示字符串的開頭和結尾有換行符? 我正在寫一個修剪函數:
(defun trim (str)
(if (string-match "^[[:space:]]*\\(.+?\\)[[:space:]]*$" str)
(match-string 1 str)
str))
但是使用像“first / nnext”這樣的字符串(從shell-command-to-string
)它只返回“first”。 參考手冊說:
匹配字符串而不是緩沖區時,'^'在字符串的開頭或換行符后匹配。
\\\\'
和左邊的是緩沖區的開頭/結尾,所以它只是從字符串中返回任何內容。 因此,如果可能的話,如何指示字符串的“絕對”開頭?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.