From: Hassan Schroeder Date: 2010-10-02T11:35:06+09:00 Subject: Re: Ruby String: How do I strip anything between two parenthesis On Fri, Oct 1, 2010 at 7:20 PM, Frank Guerino wrote: > Given a string that contains one or more substrings within parenthesis, > such as: > > myString = 'This is (variable length substring #1) (variable length > substring #2) string' > > How would I effectively strip out anything between any two parenthesis > and replace it with a blank (eliminating such substrings) such that it > would look like: > > myString = 'This is a string' >> myString => "This is (variable length substring #1) (variable length\nsubstring #2) string" >> myString.gsub(/\([^)]+\)\s+/,'') => "This is string" Interpolating an "a" in there is another story :-) HTH, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com twitter: @hassan