From: Jeff Pritchard Date: 2006-06-03T13:12:13+09:00 Subject: Re: Pattern Matching Question mitchell wrote: > If I had the text "{ hello \\} there }", what regex could I use to get > "hello } there" back? I'm really stumped on this one. Hi Mitchell, I'm puzzled by the simplicity of your question. Does it tell the whole story? If so, you could simplify the whole thing down to: a, b = input.scan(/\w+/) # find the two words - there are always two words, right? output = "#{a} } #{b}" # output the two words with a space brace space in the middle Or maybe it is always just like you show it, and all you want to do is remove the '\\' and the outer braces and spaces, in which case it is as simple as: output = input[2..-3].gsub!(%r{\\},'') Just trying to suggest that with a pattern matching question one needs a bit more context in order to know how simple or complicated the matching needs to be. But then, maybe if you told us you would have to shoot us. :) best, jp -- Posted via http://www.ruby-forum.com/.