# How i can to parse string

**URL:** <https://rubytalk.org/t/how-i-can-to-parse-string/26949>\
**Category:** ruby-talk\
**Created:** [26 April 2006 13:29 UTC](https://rubytalk.org/t/how-i-can-to-parse-string/26949 "2006-04-26T13:29:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kroeger\_Simon\_ext](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@Kroeger\_Simon\_ext](https://rubytalk.org/u/Kroeger_Simon_ext)\
**Post date:** [26 April 2006 13:29 UTC](https://rubytalk.org/t/how-i-can-to-parse-string/26949/1 "2006-04-26T13:29:07Z")

</div>

> [..]  
> But... but... neither of you guys's version gives the same result as  
> Jonh's 🙂
> 
> I think this does:
> 
> Hash[\*str.scan(/([^,]+)=([^,]+)/).flatten]
> 
> David

or

Hash[\*str.split(/=|,/)]

cheers

Simon

---

<div class="post-metadata">

**Author:** ![David\_A\_Black3](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@David\_A\_Black3](https://rubytalk.org/u/David_A_Black3)\
**Post date:** [26 April 2006 17:21 UTC](https://rubytalk.org/t/how-i-can-to-parse-string/26949/2 "2006-04-26T17:21:22Z")

</div>

Hi --

> **···**
>
> On Wed, 26 Apr 2006, Kroeger, Simon (ext) wrote:
> 
> > > [..]  
> > > But... but... neither of you guys's version gives the same result as  
> > > Jonh's 🙂
> > > 
> > > I think this does:
> > > 
> > > Hash[\*str.scan(/([^,]+)=([^,]+)/).flatten]
> > > 
> > > David
> > 
> > or
> > 
> > Hash[\*str.split(/=|,/)]
> 
> Oh, right -- or that 🙂 Another demonstration of the principle that  
> as one works on Ruby code it evaporates from the screen, \*and\* becomes  
> clearer rather than more cryptic.
> 
> David
> 
> --  
> David A. Black (dblack@wobblini.net)  
> Ruby Power and Light, LLC ([http://www.rubypowerandlight.com](http://www.rubypowerandlight.com))
> 
> "Ruby for Rails" PDF now on sale! [Ruby for Rails](http://www.manning.com/black)  
> Paper version coming in early May!
