Reputation: 7234
I have this string :
temp = "["minutes", "hours"]"
If I do this:
temp[1..-2].split(", ")
I get an array of 2 elements like this:
[0] = ""minutes""
[1] = ""hours""
How can I avoid to have double quotes?
Upvotes: 1
Views: 829
Reputation: 2679
One more:
the_string.scan(/\"(\w+)\"/).flatten
=> ["minutes", "hours"]
Upvotes: 2
Reputation: 759
Just do:
temp.gsub("\"", "")[1..-2].split(", ")
Or, once you have the array with double quotes on each element:
temp.map{|e| e.squeeze("̣\"")}
Upvotes: 1