The configuration file of authpcre (usually authpcrerc) is a list of comments and regular expressions. A comment is a line starting with any number of whitespaces followed by a ``#''. Whitespaces outside regular expressions are ignored. A regular expression starts with any nonblank character beside ``#'' and ``\'' that acts as a terminator. It is followed by a perl style regular expression (man perlre), the terminator, the string to substitute, another terminator and a list of options.
The string to substitute may contain a $1, $2, $3 and so on that respectively indicate the first matched string, the second one and so on ($0 indicates the whole match)...
Characters are escaped using a ``\''. Supported options are:
# This is a
# valid configuration file
/\%/@/ # Replaces the first % found with an @
$mail\.$$i # gets rid of any mail. in the username or domain part
# in a case insensitive way (watch out if you have any
# domain like mail.com or mail.org, or if any user
# uses mail. as his login name :-)
/^([^@]*)@mail\.([^.]*\..*)$/$1@$2/i # same thing as above, but matches only the domain part
# and ensures that we are removing only subdomains
~@foo.com$~@bar.com~i # changes domain foo.com in bar.com