On Fri, Oct 1, 2010 at 9:20 PM, Frank Guerino
<frank.guerino / traverseit.com>wrote:

> Hi,
>
> 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'
>
> 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 via http://www.ruby-forum.com/.
>
>
What if your substrings have parentheses in them? How do you know, when you
come to a parenthesis, whether it terminates your substring, or is a
character within your substring?

Example:
myString = '1(a)2(b)3'

That could be either "1(substring)3"
where substring is "a)2(b"

Or it could be "123"
with two substrings of "a" and "b"

How do you know which it supposed to be?