From owner-freebsd-questions@FreeBSD.ORG Sun Nov 30 18:19:36 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8631C1065672 for ; Sun, 30 Nov 2008 18:19:36 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 0A83F8FC13 for ; Sun, 30 Nov 2008 18:19:35 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.3/8.14.3) with ESMTP id mAUIJRFv063494; Sun, 30 Nov 2008 18:19:28 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.7.2 smtp.infracaninophile.co.uk mAUIJRFv063494 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1228069168; bh=L2h5pRPuMTidiT qJyf2bh66A3zX/tJpugzpFrSXszTQ=; h=Message-ID:Date:From:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Cc:Content-Type: Date:From:In-Reply-To:Message-ID:Mime-Version:References:To; z=Mes sage-ID:=20<4932D91F.5040804@infracaninophile.co.uk>|Date:=20Sun,=2 030=20Nov=202008=2018:19:11=20+0000|From:=20Matthew=20Seaman=20|Organization:=20Infracaninophile|User -Agent:=20Thunderbird=202.0.0.18=20(X11/20081125)|MIME-Version:=201 .0|To:=20Drew=20Tomlinson=20|CC:=20FreeBSD =20Questions=20|Subject:=20Re:=20Reg ular=20Expression=20Help|References:=20<4932CA0D.8080109@mykitchent able.net>|In-Reply-To:=20<4932CA0D.8080109@mykitchentable.net>|X-En igmail-Version:=200.95.6|Content-Type:=20multipart/signed=3B=20mica lg=3Dpgp-sha256=3B=0D=0A=20protocol=3D"application/pgp-signature"=3 B=0D=0A=20boundary=3D"------------enig108C1DB5D46C91DE784207F4"; b=PM9TH+CXRFe4afAyQPjJmSfMTFIsSNkKo+Lkjqd7YGdKhxFb9VYEkl4dpKkk9E+fI 0851Q+C87bjD5z/j7/FsgH8q/wzC4jiLFvuchUB82Of520ESKZQ8pUSY1HjcQ9tnhll L500tZ7qivCPcgTpRBYM6SrHHD70gFrXN0bLJ8Q= Message-ID: <4932D91F.5040804@infracaninophile.co.uk> Date: Sun, 30 Nov 2008 18:19:11 +0000 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: Drew Tomlinson References: <4932CA0D.8080109@mykitchentable.net> In-Reply-To: <4932CA0D.8080109@mykitchentable.net> X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig108C1DB5D46C91DE784207F4" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (smtp.infracaninophile.co.uk [IPv6:::1]); Sun, 30 Nov 2008 18:19:28 +0000 (GMT) X-Virus-Scanned: ClamAV 0.94.2/8698/Sun Nov 30 15:09:19 2008 on happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: FreeBSD Questions Subject: Re: Regular Expression Help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Nov 2008 18:19:36 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig108C1DB5D46C91DE784207F4 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Drew Tomlinson wrote: > I'm attempting to take an ldiff file and flip first/last name order. =20 > However I can not figure out how to match hyphenated last names. In=20 > vim, my current search/replace string is: >=20 > %s/cn=3D\(\w\+\-*\) \(\w\+\),/cn=3D\2 \1,/gc >=20 > This will match: >=20 > cn=3DSmith Joe, >=20 > and replace it with: >=20 > cn=3DJoe Smith, >=20 > But it will not match: >=20 > cn=3DSmith-Brown Joe, >=20 > nor replace it with: >=20 > cn=3DJoe Smith-Brown, >=20 > I've tried various incantations of escaping and quantifying yet I can=20 > not figure out how to do what I want. Well, assuming that none of the surnames contain ',' and that the first '= ' (space) is always the delimiter between the surname and that anything els= e is forenames ...=20 % cat foo.txt=20 cn=3DSmith Joe, cn=3DSmith-Brown Joe, % perl -p -e 's/cn=3D([^ ,]+) ([^,]+),/cn=3D$2 $1,/' < foo.txt=20 cn=3DJoe Smith, cn=3DJoe Smith-Brown, ie. you need a s/// command that understands negated character classes. = I think sed(1) and vi(1) will do that, but I haven't time to look up the pr= ecise syntax. Perl, of course, just does the job for me. 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 --------------enig108C1DB5D46C91DE784207F4 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.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAkky2S8ACgkQ8Mjk52CukIxj7ACfSDDR6rlLZD2jrcqchD3wZn76 VvUAmwWmew53xvsyMmB84SO2NhWVtBOv =+rGm -----END PGP SIGNATURE----- --------------enig108C1DB5D46C91DE784207F4--