Regexp help please

Hi All,

I am trying to extract quoted text fromlines in a file. Assume I have
read in a line as follows

type “this piece of text” into field called “search field”

I then want to extract the two pieces of quoted text from this line.
I’m halfway there with this
line =~ /(".*?")/
this will match the first piece of quoted text, which I can access
with $1. I’m having trouble getting the match to carry on & match the
next piece of quoted text.

Any help greatly appreciated :slight_smile:

Many Thanks


453/22 > irb
irb(main):001:0> a=%<“first” and “second”>
=> “"first" and "second"”
irb(main):002:0> a.scan /“.*?”/
=> [“"first"”, “"second"”]


AALST (n.) One who changes his name to be further to the front
D.Adams; The Meaning of LIFF


line=%<“first” and “second”>
line =~ /(".?")[^"](".*?")/

puts $1 # => “first”
puts $2 # => “second”

The [^"]* means “zero or more characters that aren’t a doublequote


Thanks Robert, that was exactly what I was looking for. I knew there
had to be a simple way to do it in Ruby. I love Ruby!!