From: Joe Cheng Date: 2004-10-05T13:49:51+09:00 Subject: Re: Regexp match question on interpolated strings... Richard Kilmer wrote: > If I had the source for a string: > > "name = #{person.first_name+" "+person.last_name} ... Ok?" > > And assuming I could find the first and last double quotes, how would I > parse out the #{ ... } with a regular expression since anything can fall > between the #{ ... } braces in a string? Hmmm, if I understand your question, and if you really knew where the first and last double quotes were, you could calculate the number of chars between them, and do something like this: /#\{.*?\".{}\".*?}/ But it seems like if you want to be able to get more dynamic/flexible than that, you really want to parse the expression for real--which is something I believe regexes aren't powerful enough for. You'd either have to write a parser by hand, or use something like racc: http://i.loveruby.net/en/prog/racc.html