@c Copyright (C) 2009-2011 Sergey Poznyakoff @c Permission is granted to copy, distribute and/or modify this document @c under the terms of the GNU Free Documentation License, Version 1.3 or @c any later version published by the Free Software Foundation; with no @c Invariant Sections, with the Front-Cover texts being ``Mailfromd Manual'', @c and with the Back-Cover Texts at your option. @cindex s-expression An @dfn{s-expression} is a @command{sed}-like transformation expression: @smallexample s/@var{regexp}/@var{replace}/[@var{flags}] @end smallexample @noindent where @var{regexp} is a @dfn{regular expression}, @var{replace} is a replacement for each part of the input that matches @var{regexp}. Both @var{regexp} and @var{replace} are described in detail in @ref{The "s" Command, The "s" Command, The `s' Command, sed, GNU sed}. As in @command{sed}, you can give several replace expressions, separated by a semicolon. Supported @var{flags} are: @table @samp @cindex g, @option{transform} flag @item g Apply the replacement to @emph{all} matches to the @var{regexp}, not just the first. @cindex i, @option{transform} flag @item i Use case-insensitive matching @cindex x, @option{transform} flag @item x @var{regexp} is an @dfn{extended regular expression} (@pxref{Extended regexps, Extended regular expressions, Extended regular expressions, sed, GNU sed}). @item @var{number} Only replace the @var{number}th match of the @var{regexp}. Note: the @acronym{POSIX} standard does not specify what should happen when you mix the @samp{g} and @var{number} modifiers. @command{Mailfromd} follows the GNU @command{sed} implementation in this regard, so the interaction is defined to be: ignore matches before the @var{number}th, and then match and replace all matches from the @var{number}th on. @end table Any delimiter can be used in lieue of @samp{/}, the only requirement being that it be used consistently throughout the expression. For example, the following two expressions are equivalent: @smallexample @group s/one/two/ s,one,two, @end group @end smallexample Changing delimiters is often useful when the @var{regex} contains slashes. For instance, it is more convenient to write @code{s,/,-,} than @code{s/\//-/}.