On Oct 1, 9:20=A0pm, Frank Guerino <frank.guer... / traverseit.com> wrote:
> Hi,
>
> Given a string that contains one or more substrings within parenthesis,
> such as:
>
> myString =3D '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 =3D 'This is a string'
>
> I'm assuming the answer would be a combination of the string "remove"
> command and the use of regular expressions but can't seem to get it to
> work.
>
> Thanks for any help you can offer.
>
> My Best,
>
> Frank
> --
> Posted viahttp://www.ruby-forum.com/.

my_string =3D "This is (variable length substring #1) " +
"(variable length substring #2) string"
my_string.gsub( /\(.*?\)/, " " ).squeeze(" ")
    =3D=3D>"This is string"