Emmanuel Touzery wrote:

> Szymon Drejewicz wrote:
>
>> I have string
>> a = "ala $(ela) ola $(tola) lola $(p_ola) ".
>>
>> And I need some magic function that works this way:
>>
>> >> puts a.params
>> ["ela", "tola", "p_ola"]
>>
>> How to do this?
>
>
> just escape the ( and the $.
>
> irb(main):001:0> a = "ala $(ela) ola $(tola) lola $(p_ola) "
> => "ala $(ela) ola $(tola) lola $(p_ola) "
> irb(main):002:0> a.scan /\$\((\w+)\)/
> => [["ela"], ["tola"], ["p_ola"]]
> irb(main):003:0>
>
> emmanuel
>
btw if you just want a one-depth array:

irb(main):004:0> a.scan(/\$\((\w+)\)/).flatten
=> ["ela", "tola", "p_ola"]

emmanuel