Matthew Seaman wrote:
Drew Tomlinson wrote:
I'm attempting to take an ldiff file and flip first/last name order.
However I can not figure out how to match hyphenated last names. In
vim, my current search/replace string is:
%s/cn=\(\w\+\-*\) \(\w\+\),/cn=\2 \1,/gc
This will match:
and replace it with:
But it will not match:
nor replace it with:
I've tried various incantations of escaping and quantifying yet I can
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
is forenames ...
% cat foo.txt cn=Smith Joe,
% perl -p -e 's/cn=([^ ,]+) ([^,]+),/cn=$2 $1,/' < foo.txt cn=Joe Smith,
ie. you need a s/// command that understands negated character
think sed(1) and vi(1) will do that, but I haven't time to look up the
syntax. Perl, of course, just does the job for me.
Thank you for your reply. The particular editor I was attempting to use
is vim 7.1.315. However it doesn't like the above string so I tried you
perl example verbatim. It works and even handles such lines as:
cn=Smith-Brown Joe & Jane,
cn=Joe & Jane Smith-Brown,
which I hadn't considered.
I still don't really understand *why* the above works but I'm trying to
pick it apart now.
Thanks to you and the others for the replies.
Be a Great Magician!
Visit The Alchemist's Warehouse
firstname.lastname@example.org mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"