Date: Mon, 01 Dec 2008 06:36:36 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Drew Tomlinson <drew@mykitchentable.net> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Regular Expression Help Message-ID: <493385F4.6010809@infracaninophile.co.uk> In-Reply-To: <4932E8A2.6030804@mykitchentable.net> References: <4932CA0D.8080109@mykitchentable.net> <4932D91F.5040804@infracaninophile.co.uk> <4932E8A2.6030804@mykitchentable.net>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Drew Tomlinson wrote:
> Matthew Seaman wrote:
>> % perl -p -e 's/cn=([^ ,]+) ([^,]+),/cn=$2 $1,/' < foo.txt
> I still don't really understand *why* the above works but I'm trying to
> pick it apart now.
The RE breaks down like this:
/cn=([^ ,]+) ([^,]+),/
cn= Match literal text 'cn='
( capture #1 begin
[^ ,] Character class: anything that is not space or comma
+ At least one of the above
) end capture #1
Match a literal space
( capture #2 begin
[^,] Character class: anything that is not a comma
+ At least one of the above
) end capture #2
, Match literal comma
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 #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEAREIAAYFAkkzhfsACgkQ8Mjk52CukIxGvwCgkVhmWcapYq6lVOxbuJdhtYDd
vHcAn1zUhhXsVkOt9kmDtbJjRXIsDCc3
=L8PS
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?493385F4.6010809>
