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?
search-forward-regexp
interactively, in which case your regexps need to be instring
syntax rather thanread
syntax.\
is a literal backslash, so the regexp[^\*]\*
matches any character except a backslash or an asterisk, followed by an asterisk.