Regular Expression Help

Drew Tomlinson drew at mykitchentable.net
Sun Nov 30 09:15:07 PST 2008


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:

cn=Smith Joe,

and replace it with:

cn=Joe Smith,

But it will not match:

cn=Smith-Brown Joe,

nor replace it with:

cn=Joe Smith-Brown,

I've tried various incantations of escaping and quantifying yet I can 
not figure out how to do what I want.

Please show me my error.

Thanks,

Drew

-- 
Be a Great Magician!
Visit The Alchemist's Warehouse

http://www.alchemistswarehouse.com



More information about the freebsd-questions mailing list