No need to use flatten if you don’t use the (unnecessary) grouping:
a.scan( /"[^"]+"/ )
or
a.scan( /".+?"/ )
(Both, of course, assuming no escaped backslashes in the content. It’s
not hard to come up with a regexp that accepts those, though at some
point perhaps Ara’s eval solution is easier.)
(Both, of course, assuming no escaped backslashes in the content. It’s
not hard to come up with a regexp that accepts those, though at some
point perhaps Ara’s eval solution is easier.)
Though that will capture the surrounding quotes as well, which was not
specified in the requirements.
Tom W.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.