Beginning and end of the string in Emacs regexps

六月ゝ 毕业季﹏ 提交于 2019-12-05 21:57:04
event_jr

It's \\` for beginning of buffer or string. And \\' for end. See manual

However, I think the root of your confustion isn't the anchor. The [:space:] char class matches different characters based on the current syntax table. To reliably match a non-printing or printing character use [:graph:]. See char class

Also . won't match newlines.

E.g.

(let ((str " \n a\nbc \n "))
  (string-match "\\`[^[:graph:]]*\\(\\(?:.\\|\n\\)+?\\)[^[:graph:]]*\\'" str)
  (match-string 1 str))
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!