-1

I have evil-mode installed and am trying to get PCRE regexes working everywhere.

I currently have pcre2el installed (https://github.com/joddie/pcre2el) and evil mode installed as well. I also have pcre2el turned on everywhere with

(pcre-mode t)

As an example, I want to search and replace for bar followed by any number of digits in the following file:

baraaa
bar123123
bar44323
bar33232

If I do an incremental search, it works. E.g. if I do this:

/foo(\d+)

It works. It finds lines 2, 3 and 4 and highlights them all appropriately, finding the all of the digits after foo.

Search and replace, however, does not use the PCRE regexes. If I do this:

:%s/foo(\d+)/f\1oo/

It does not recognize the parens (it thinks they need to be entered as \( and \)) and it does not recognize \d as a character class -- I need to do the following to get it to work:

:%s/foo\([0-9]+\)/f\1oo/

Is there something I'm missing here, or is it just that the pcre2el package does not work with search and replace in evil mode?

  • Does it work with standard emacs commands like isearch and query replace? Given that pcre-mode is experimental, it's likely that it won't work properly with third party commands. – Qudit Dec 28 '18 at 20:58
  • It works with M-x query-replace-regexp. The help text in the mini-buffer says "[PCRE] Query replace regexp" and I can do this successfully: M-x query-replace-regexp <return> foo(\d+) <return> f\1oo <return>. It does not work for re-search-forward`. – Scott Patten Dec 28 '18 at 22:01
  • I suggest you file a bug report. The page indicates that the mode is experimental and bug reports are welcome. – Qudit Dec 28 '18 at 22:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.