
Untitled
By: a guest on
May 31st, 2012 | syntax:
None | size: 0.55 KB | hits: 10 | expires: Never
ruby incorrect method behaviour (possible depending charset)
irb(main):002:0> pp " LS 600"
"302240302240302240302240LS 600"
irb(main):003:0> pp " LS 600".strip
"302240302240302240302240LS 600"
# Ruby 1.9.2 only.
# Remove any whitespace-like characters from beginning/end.
"302240302240LS 600".gsub(/^p{Space}+|p{Space}+$/, "")
# Ruby 1.8.7/1.9.2.
$KCODE = "u"
require "rubygems"
require "active_support/core_ext/string/multibyte"
# Remove any whitespace-like characters from beginning/end.
"302240302240LS 600".mb_chars.strip.to_s