James Edward Gray II wrote: > > On Oct 4, 2004, at 10:27 PM, 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? > > > I would use: > > .sub(/^(.+?)\#\(.+\}/m, '\1') This would be: .sub(/^(.+?)\#\{.+\}/m, '\1') ^ Why are you preferring the greedy match? And if I get it right this substitutes "name = #{person.first_name+" "+person.last_name} ... Ok?" to "name = ... Ok?" I don't think that is what is asked? Or am I wrong? regards, Brian > > Hope that helps. > > James Edward Gray II > > -- Brian Schröäer http://ruby.brian-schroeder.de/