使用regexp和spec. chars的Elisp前向搜索返回nil



emacs 25.1

我有string:

<p>more complex non Q and A HTML code here.</p><table class="waffle" cellspacing="0" cellpadding="0"><thead><tr><th

如果在emacs regexp-builder中使用下一个regexp: "<table .*?>"

it's success found text:

<table class="waffle" cellspacing="0" cellpadding="0">

OK。但是当我在elisp中使用相同的正则表达式时,通过函数向前搜索没有找到(返回nil)

      (setq test-start-point (search-forward "<table .*?>" nil t))

test-start-point = nil.

为什么?

search-forward搜索精确匹配。在您的示例中,您希望搜索正则表达式模式,因此您希望使用re-search-forward代替。

最新更新