From: "Bermejo, Rodrigo" Date: 2004-02-12T10:09:23+09:00 Subject: Re: (noob) cast string to array? # sub { block way! } result.sub!(/\{(.+)\}/) { "["+$1+"]" } -ronnie. Simon Strandgaard wrote: >On Thu, 12 Feb 2004 00:31:29 +0000, Koncept wrote: > > >>Hi. What a fantastic language. This is my first day learning using it >>and I *love* it so far. >> >> > >Great.. Welcome to Ruby. > >[snip] > > >>result = result.sub(/\{/,'[') >>result = result.sub(/\}/,']') >> >> > >What you has written is the same as (notice the '!' suffix) > > result.sub!(/\{/,'[') > result.sub!(/\}/,']') > >Above can be chained, so it becomes > > result.sub!(/\{/,'[').sub!(/\}/,']') > > > >>Any suggestions are more than welcome. >> >> > >Try 'gsub' > > result.gsub!(/\{/,'[').gsub!(/\}/,']') > > >-- >Simon Strandgaard > >