On 18 Dec 2002, Tore Anderson wrote:
> > exim -be '${sg{foo;bar\;baz\\;zot\\\;biff\\\\;bing}{\\\\*;}{\\\\\\;}}'
> >
> > The problem is, that first exim unescapes the \\ to \ then then pcre
> > will do so too, your string would result in
>
> Aha. I wonder why this behaviour isn't documented.
It is documented. From spec.txt:
${sg{<subject>}{<regex>}{<replacement>}}
This item works like Perl's substitution operator (s) with the global (/g)
option; hence its name. However, unlike the Perl equivalent, Exim does not |
modify the subject string; instead it returns the modified string for |
insertion into the overall expansion. The item takes three arguments: the |
subject string, a regular expression, and a substitution string. For
example
${sg{abcdefabcdef}{abc}{xyz}}
yields 'xyzdefxyzdef'. Because all three arguments are expanded before use,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
if any $ or \ characters are required in the regular expression or in the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
substitution string, they have to be escaped.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--
Philip Hazel University of Cambridge Computing Service,
ph10@??? Cambridge, England. Phone: +44 1223 334714.