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
signature.asc
Description: OpenPGP digital signature