[英]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.