Date: Fri, 15 Jan 2010 09:03:57 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: freebsd-questions@freebsd.org Subject: Re: Regular Expression Editor Message-ID: <4B502F7D.3000107@infracaninophile.co.uk> In-Reply-To: <BLU0-SMTP78C48F3BB9D14DBAF3C88B936A0@phx.gbl> References: <BLU0-SMTP87607E292253E8D30ADD68936A0@phx.gbl> <866374fs5q.fsf@blue.stonehenge.com> <BLU0-SMTP78C48F3BB9D14DBAF3C88B936A0@phx.gbl>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA2F0D72D4E2D725FDA1317F9 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Carmel wrote: > On Thu, 14 Jan 2010 10:38:41 -0800 > Randal L. Schwartz <merlyn@stonehenge.com> replied: >=20 >> 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? >=20 > 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. >=20 I believe dovecot simply uses the standard posix 'extended regular expression' syntax as seen in programs like grep(1). [See: http://ietfre= port.isoc.org/idref/draft-ietf-sieve-regex ]=20 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 --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enigA2F0D72D4E2D725FDA1317F9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAktQL4MACgkQ8Mjk52CukIzjCACfcqU3vgcenoE4zeeIE97d2K3C kQsAniiLBfWLoXDNTd/K0Mz8L3UiSrvR =2etF -----END PGP SIGNATURE----- --------------enigA2F0D72D4E2D725FDA1317F9--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B502F7D.3000107>