0

Following Org mode refiling gobbles a newline and absorbs the next heading where Org mode refiling has gobbled some of the next heading, I want to search for those gobbled headings where the stars are not preceded by newlines. I wrote this regular expression with re-builder:

[^
\\*]\\*

It shows 16 matches and I confirmed that some are relevant. But search-forward-regexp with the same expression matches every character. I suspected it was due to escaping the backslash in the re-builder literal, which uses double-quotes, and search-forward-regexp with

[^
\*]\*

works to find lone stars.

I did not see double backlashes in the manual page.

Why does this happen, and when do backslashes need to be escaped?

2
  • 1
    Does the related Q&A emacs.stackexchange.com/q/5568/454 answer this for you? I suspect that you are using search-forward-regexp interactively, in which case your regexps need to be in string syntax rather than read syntax.
    – phils
    Nov 3, 2019 at 8:57
  • 1
    Also note that within a character alternative (square brackets) \ is a literal backslash, so the regexp [^\*]\* matches any character except a backslash or an asterisk, followed by an asterisk.
    – phils
    Nov 3, 2019 at 9:00

0

Browse other questions tagged or ask your own question.