I have an array that contains non-breaking spaces that I want to get rid of. I want to either strip them as it goes into the array or remove them once in. The solution needs to retain regular spaces and nil entries will end up in the array.
Whatever I try the array remains unchanged. I am just learning Ruby and not really a coding superstar to start off with but I’m trying!
Here is what I have:
myarray = [“foo\u00A0”, “foo bar\u00A0”, “foo foo bar\u00A0”]
I want to end up with:
myarray = [“foo”, “foo bar”, “foo foo bar”]
I have tried:
myarray.map {|word| word.gsub(’\u00A0’,’’) }
and
myarray.map {|word| word.gsub(’/[[:space:]]/’,’’) }
Any help is appreciated.
Edited to correct some of the slashes I had going in the wrong direction