For example I have the following string:
str = “Hello world”
When I do something like this it returns a two-dimensional array:
str.scan(/Hello (.*)/) #[[“world”]]
I have to do the following to get the result as a string:
str.scan(/Hello (.*)/).flatten.first
IMO this is not efficient, how can I get the result with just the method
‘first’ instead of ‘flatten.first’?
In other words I want my results in a one dimensional array.
I’m sure I’m doing something wrong,. but I don’t know what. Anyone any
idea?