0
给定的字符串正确的密钥和值我有一个列表:如何解析为使用Ruby
key1:this is an{example{of an example}I like} key2:this is another example key3: this is secondary{example{of an example}}
我需要单独的钥匙,通过差异比较键的值,所以结果我想获得是:
{
:key1 => 'this is an [example[of an example]I like]',
:key2 => 'this is another example',
:key3 => 'this is secondary[example[of an example]]'
}
是这样或类似的东西可能与Ruby或正则表达式?
你想返回什么?哈希?一个字符串? – Mischa 2013-03-19 14:42:15
我希望它是散列。我目前试图使用拆分和正则表达式除以“:”和“{}”,就我所知 – lifejuggler 2013-03-19 14:51:12
我编辑了你的问题,以便所需的返回值看起来像一个散列。目前还不清楚你的所有方括号是什么意图。随时再次编辑,以明确。 – Mischa 2013-03-19 15:08:11