RE: parse x.500 DN and change order displayed



Peter Scott <Peter@xxxxxxxx> wrote:

On Sun, 30 Mar 2008 20:36:58 -0700, SecureIT wrote:
I am trying to change this

"cn=Bob Smith+serialNumber=CR013120080827,o=ICM,c=US"

to this:

"serialNumber=CR013120080827+cn=Bob Smith,o=ICM,c=US"

s/^(cn=.*?)+(.*?),/$2+$1,/;

Close, but no cigar ;-)

+ is a quantifier meaning 1 or more matches of the
preceeding expression, so you'll end up with all of
the string up to , in $1 and nothing in $2.

You'll have to escape it to match a literal '+'.

I would also drop the ^ since it is unclear if the
data is indeed without leading whitespace and/or
quotes.

HTH,
Thomas
.