Ruby 1.9 strip not removing whitespace
问题 Im doing some screen scraping and im getting back a string that appears to end with whitespace but neither string.strip or strip.gsub(/\s/u, '') removes the character. Im guessing it's a character encoding issue. Any suggestions? 回答1: I think, there are a lot of "space characters". You can use something like this: my_string.gsub("\302\240", ' ').strip 回答2: You can try this: my_string.gsub(/\A[[:space:]]+|[[:space:]]+\z/, '') This should remove all space characters from the beginning and the