Code:
digits.each do |digit|
puts digit.content #&0000000000032056.00000032 056
value = digit.content[24..-1].strip
puts value #32 056 it's ok
puts value.gsub(/\s+/, "") #32 056 !!!! I expected 32056
population << value
end
I don’t understand why gsub does not work as I expected :/ Could somebody help?
[EDIT]
Anyway I do it another way:
value = digit.content.split(".")[0]
value = value[12..-1].strip
but I am still wonder, why first solution sucks.
Two things to try:
If you’re checking the
populationvariable, your method doesn’t actually put the substitution in it. Change the last line to:If that still doesn’t work, perhaps there is some non-space character that looks like a space in your terminal? Try replacing non-digits instead: