Carmel wrote:
On Thu, 14 Jan 2010 10:38:41 -0800
Randal L. Schwartz <[email protected]> replied:

You need to be specific about the kind of regex.  While most regexp
engines have common things like . and * and ^ and $, the meanings may
vary a bit, and the more exotic things are certainly going to vary.

(For example, despite the name, "Perl Compatible [sic] Regular
Expressions" are *not* Perl compatible.)

What tool are you using your regexes with?

OK, I was using RegExp Buddy <http://www.regexbuddy.com/> on a Windows
machine. I would like to find something similar to it for a FreeBSD
environment. The expressions I create are used primarily with 'sieve'
in conjunction with Dovecot. I am also thinking of possibly creating a
few for use with Postfix.


I believe dovecot simply uses the standard posix 'extended regular
expression' syntax as seen in programs like grep(1). [See: http://ietfreport.isoc.org/idref/draft-ietf-sieve-regex ]
In principle, this means you can write your test data into a file, and
test it by running it through grep(1) using the -E flag:

  grep -E 'foo@(bar|baz)\.org' < testdata.txt

Postfix uses PCRE by default. You can do the same sort of trick there:
just run 'pcregrep' rather than 'grep -E'

However, note that the regexes in dovecot sieve scripts are subject to
a level of shell expansion. (Not sure what happens with postfix.) This
means various special characters are going to need to be escaped by
preceding them with a *pair* of backslashes.  So, in the example above,
the bit that says '\.' (meaning override the usual meaning of '.' as a
wildcard that will match any character, and instead match a literal '.')
would have to be entered into  your sieve script as '\\\.'  If in doubt,
simply pound on the backslash key a few more times...

        Cheers,

        Matthew


--
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                 Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                 Kent, CT11 9PW

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to