View Single Post
Old 3 Sep 2019, 11:11 PM   #25
SideshowBob
Essential Contributor
 
Join Date: Jan 2017
Posts: 278
Quote:
Originally Posted by JamesHenderson View Post
Thanks, xyzzy.

I got the gist of your code (thanks). but my question was specifically why two slahes were needed in succession. I can see that Fastmail translates my single slash into two, but why? ...I cannot see any reference to double-shlashing having a special meaning in regex (it seems to me that the first slash escapes the second slash).
It's because the escaping is happening at two separate levels.

In sieve a \ is used to escape the double quote character that's normally the string delimiter, and a literal \ itself has to be escaped as \\. Other backslashes are ignored. This is done before the regex string is passed to the regex library.
SideshowBob is offline   Reply With Quote