我正在寻找一个函数,它会尝试查找并返回正则表达式\\(\\S-\\)
匹配的内容,如果找不到任何内容,则可能为nil。搜索应从(point)
开始,然后搜索到文档的末尾。
答案 0 :(得分:7)
使用re-search-forward
和match-string
:
(when (re-search-forward "\\(\\S-\\)" nil t)
(match-string 1))
如果您不想移动点,请将其包裹在save-excursion
:
(save-excursion
(when ...