From: timr Date: 2010-10-02T16:25:16+09:00 Subject: Re: Ruby String: How do I strip anything between two parenthesis 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" >> "no match outside (lisp? (atom? (car (me_a_string 3 4)))".match(/\((.*)\)/)[1] => "lisp? (atom? (car (me_a_string 3 4))" Explanation: /\((.*)\)/ / <- regex syntax -> / means look for a pattern matching \( an open parenthesis (the backslash is working as an escape character here) (.*) means as many characters as you can find (even none is okay) and store the hit \) a close parenthesis (again backslash is just an escape character)