Rails Strip方法无法正常工作

MMa*_*gun 1 ruby-on-rails strip gsub

因此,以防万一有人偶然发现同一问题,我有一个字符串:

a = " I am a string with whitespace at the start and end "

有趣的是,尝试执行时a.strip,我的字符串更改为:

a = "I am a string with whitespace at the start and end"

MMa*_*gun 5

这里的问题是,我所处 的空间或其他某种空间无法strip发挥其最大作用。

我的解决方案,首先用空格替换所有空格:

a.gsub("\u00A0", " ")(我a.gsub(" ", " ")最初尝试过,但是没有运气)

多田!

现在我得到了预期的a.strip结果:)

(如果有的话,也许有一种更清晰的方法可以执行此操作)