From: 7stud -- Date: 2011-03-25T09:31:40+09:00 Subject: Re: Regexp, matching only the content within parentheses Regexes are "greedy" by default. Don't look for [^)] characters, instead look for a closing parentheses: str = "aaa( abc(def)ghi (jkl)(mno) )" if (str =~ /[(] .* [)]/xms ) puts Regexp.last_match[0] end --output:-- ( abc(def)ghi (jkl)(mno) ) How you will know when to use non-greedy patterns, like [^)] or .*?, versus the natural greediness of a regex is not clear to me. -- Posted via http://www.ruby-forum.com/.