regex: attribute list to Ruby hash

Snippet to convert a list of attributes to a Ruby hash.

Input:

cn:ID
sn:Surname
fn:FirstName

Target output:

"cn" => "ID",
"sn" => "Surname",
"fn" => "FirstName",

Regex:

/(.+?)(?=\:):(.*$)/"$1" => "$2",/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s