From: "Jesús Gabriel y Galán" Date: 2010-10-02T18:04:03+09:00 Subject: Re: Ruby String: How do I strip anything between two parenthesis On Sat, Oct 2, 2010 at 9:25 AM, timr wrote: > I'd go with regex, but we need more cases with expected results to > figure out which regex would work for you. > How about this? > >>> "no match outside (inside all (gets) collected)".match(/\((.*)\)/)[1] > => "inside all (gets) collected" This could match more than expected: irb(main):001:0> "something (this should be stripped), but not this, (and this too), and again not this".match(/\((.*)\)/)[1] => "this should be stripped), but not this, (and this too" Jesus.