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 comment