|Syntactic Confectionery Delight|
Parsing "=" separated outputby blindluke (Hermit)
|on Aug 03, 2011 at 06:46 UTC||Need Help??|
blindluke has asked for the
wisdom of the Perl Monks concerning the following question:
Hello, enlightened Monks!
I have a string, that looks a bit like this:
"sometrash key1=value0 value1, value2 key2=value3 key3=value4"
I want to extract keys and values to a hash, like this one:
I used something like the code below, but for key1 it only gives me 'value0' - I thought there wouldn't be any whitespace in the values, and I was wrong :)
How can I modify my regexp, so that it only treats a single word right before the '=' sign as the key, and all the characters up until next key (or end of string) are treated as the value?
Regards, Luke Jefferson