From: Mohit Sindhwani Date: 2008-06-03T01:27:09+09:00 Subject: Re: split a string at tab positions suresh wrote: > Hi > > I am a newbie to ruby and when i tried to split a string at tab > positions, it didnt work. Could you please tell me where I am going > wrong? Code is pasted. > > #!/usr/bin/ruby1.9 > s = "a b" > ss = s.split('\t') > puts ss[0] > > It just prints the entire line without splitting... > > suresh > > > The problem is the '\t' - anything inside single quotes is not touched by Ruby. It needs to be "\t" (double quotes) for it to be interpreted as a tab character by Ruby. In my mind, this is the #1 problem that C programmers have in Ruby - it just seems natural to split at a character \t and C programmers (incl me) write it as '\t'. Hope this helps. Cheers, Mohit. 6/3/2008 | 12:24 AM.