I'm using Ruby 2.0. I've currently got a string of:
str = "bar [baz] foo [with] another [one]"
str.scan(/\[.*\]/)
The output is:
["[baz] foo [with] another [one]"]
When I would expect it more like:
["[baz]","[with]","[one]"]
So I basically need to put everything between "[]" into an array. Can someone please show me what I'm missing out?
str.scan(/\[.*?\]/) #=> ["[baz]", "[with]", "[one]"]