Regular Expression Editor

Matthew Seaman m.seaman at
Fri Jan 15 09:04:12 UTC 2010

Carmel wrote:
> On Thu, 14 Jan 2010 10:38:41 -0800
> Randal L. Schwartz <merlyn at> 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 <> 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: ] 

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...



Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP:     Ramsgate
                                                  Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
Url :

More information about the freebsd-questions mailing list