Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 31st, 2012  |  syntax: None  |  size: 0.55 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ruby incorrect method behaviour (possible depending charset)
  2. irb(main):002:0> pp "    LS 600"
  3. "302240302240302240302240LS 600"
  4.  
  5. irb(main):003:0> pp "    LS 600".strip
  6. "302240302240302240302240LS 600"
  7.        
  8. # Ruby 1.9.2 only.
  9. # Remove any whitespace-like characters from beginning/end.
  10. "302240302240LS 600".gsub(/^p{Space}+|p{Space}+$/, "")
  11.        
  12. # Ruby 1.8.7/1.9.2.
  13. $KCODE = "u"
  14. require "rubygems"
  15. require "active_support/core_ext/string/multibyte"
  16.  
  17. # Remove any whitespace-like characters from beginning/end.
  18. "302240302240LS 600".mb_chars.strip.to_s