I’m looking for some way to get rid of collection object in collect_data method and return matched data directly.
def collect_data(string)
collection = []
string.gsub(/a\=\[(.+?)\](\s|$)/) { collection << $1 }
collection
end
Some example how it suppose to work
string = "a=[111] b=[555] a=[123]"
collect_data(string) # => ["111", "123"]
1 Answer