regex - CSR Subject with Special Characters extract -


i need extract $subj seen below snippet, looks regex isn't working expected. similar this: how string manipulate/extract subject contents in csr using openssl command + perl? different subject entry in csr. i'm not sure if did thing in regex %subjinfo

#!/usr/bin/env perl use strict; use warnings; use data::dumper;  $subj =     'subject=/o=test~@#$^()_+-=\{}|;':",./<>/ou=test~@#$^()_+-=\{}|;':",./<>/emailad‌​dress=test~@#$^()_+-=\{}|;':",./<>/l=cde/st=abc/c=au/cn=test~@#$^()_+ -=\{}|;':",./<>';  %subjinfo = ( $subj =~ m,(\w+)=([^=]*)(?:/|$),g ); print dumper \%subjinfo; 

and must give result this:

$var1 = {           'subject' => '',           'l' => 'nyc',           'c' => 'amer',           'ou' => 'test~@#$^()_+-=\{}|;':",./<>',           'emailaddress' => 'test~@#$^()_+-=\{}|;':",./<>',           'st' => 'amer',           'cn' => 'test~@#$^()_+-=\{}|;':",./<>',           'o' => 'test~@#$^()_+-=\{}|;':",./<>'         }; 

is possible? can advise?

splitting on regex looks more natural regex solution,

use data::dumper;  $subj = q(subject=/o=test~@#$^()_+-=\{}|;':",./<>/ou=test~@#$^()_+-=\{}|;':",./<>/emailaddress=test~@#$^()_+-=\{}|;':",./<>/l=cde/st=abc/c=au/cn=test~@#$^()_+ -=\{}|;':",./<>);  (undef, %subjinfo) = split m|/?(\w+)=|, $subj;  print dumper \%subjinfo; 

output

$var1 = {       'emailaddress' => 'test~@#$^()_+-=\\{}|;\':",./<>',       'cn' => 'test~@#$^()_+ -=\\{}|;\':",./<>',       'ou' => 'test~@#$^()_+-=\\{}|;\':",./<>',       'l' => 'cde',       'c' => 'au',       'st' => 'abc',       'subject' => '',       'o' => 'test~@#$^()_+-=\\{}|;\':",./<>'     }; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -