我对Emacs Lisp还不熟悉,正在学习一些基础知识。 我有一些文本像 [123],我想提取数字123。我试过了几种不同的方法,但仍然无法可靠地捕获数字。 我最接近的是提取字符]。 有人能指点我方向吗? 我最大的困难在于理解如何在使用search-forwards和search-backwards捕获括号的点位置后捕获数字。 先谢谢!
尝试 (when (re-search-forward "\\[\\([0-9]+\\)\\]" nil t) (string-to-number (match-string 1))) 或者,当光标已经在数字上方时,thing-at-point 可能更加方便: (string-to-number (thing-at-point 'sexp))