Skip to content

Instantly share code, notes, and snippets.

@ysr23
Created November 20, 2012 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysr23/4118156 to your computer and use it in GitHub Desktop.
Save ysr23/4118156 to your computer and use it in GitHub Desktop.
Problem splitting a file

using a breakpoint to inspect 'reply' in my code - but cannot figure out why it is not splitting?

[1] pry(GuideSearch)> p reply                                                                                        
 "@twellyme film"                                                                                                     
=> "@twellyme film"                                                                                                  
[2] pry(GuideSearch)> p reply.class                                                                                  
String                                                                                                               
=> String                                                                                                            
[3] pry(GuideSearch)> p reply.split                                                                                  
["@twellyme film"]                                                                                                   
=> ["@twellyme film"]

yet when i make reply 'by hand':

[4] pry(GuideSearch)> reply = "@twellyme film"                                                                       
=> "@twellyme film"                                                                                                  
[5] pry(GuideSearch)> p reply.split                                                                                  
["@twellyme", "film"]                                                                                                
=> ["@twellyme", "film"]
@wjessop
Copy link

wjessop commented Nov 20, 2012

1.9.3p286 :005 > "64 116 119 101 108 108 121 109 101 160 102 105 108 109".split.map{|c| c.to_i}.pack('c_')
=> "@twellyme\xA0film"
1.9.3p286 :006 > "64 116 119 101 108 108 121 109 101 160 102 105 108 109".split.map{|c| c.to_i}.pack('c_').split
=> ["@twellyme\xA0film"]
1.9.3p286 :007 > "64 116 119 101 108 108 121 109 101 160 102 105 108 109".split.map{|c| c.to_i}.pack('c*').gsub(/[^[:print:]]/, ' ').split
=> ["@twellyme", "film"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment