subject = 'a b c a b " a b " b a " a "'regex = /("[^"]*")|a/replaced = subject.gsub(regex) {|m|$1}puts replaced
Standard input is empty
b c b " a b " b " a "
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!