Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一个函数,它将尝试查找并返回与正则表达式匹配的任何内容,\\(\\S-\\)如果没有找到任何内容,可能会返回 nil。搜索应该从文档开始(point)并搜索到文档的结尾。
\\(\\S-\\)
(point)
使用re-search-forward和match-string:
re-search-forward
match-string
(when (re-search-forward "\\(\\S-\\)" nil t) (match-string 1))
如果您不想移动点,请将其包装在save-excursion:
save-excursion
(save-excursion (when ...