Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
strip method
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Amasa Masiarek  
View profile  
 More options May 1 2008, 10:39 pm
Newsgroups: comp.lang.ruby
From: Amasa Masiarek <a...@masiarek.com>
Date: Thu, 1 May 2008 21:39:26 -0500
Local: Thurs, May 1 2008 10:39 pm
Subject: strip method
s = <<EOS
a1\t  b1
a2\tb2
EOS

s.each{|e|
    a = e.strip.split("\t")
    p a[1]

}

output:
"  b1"
"b2"

expected output:
"b1"
"b2"

What is wrong?
--
Posted via http://www.ruby-forum.com/.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Amasa Masiarek  
View profile  
 More options May 1 2008, 10:42 pm
Newsgroups: comp.lang.ruby
From: Amasa Masiarek <a...@masiarek.com>
Date: Thu, 1 May 2008 21:42:43 -0500
Local: Thurs, May 1 2008 10:42 pm
Subject: Re: strip method
This works fine ...

s.each{|e|
    a = e.gsub(' ','').split("\t")
    p a[1]

}

--
Posted via http://www.ruby-forum.com/.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick DeNatale  
View profile  
 More options May 1 2008, 10:48 pm
Newsgroups: comp.lang.ruby
From: Rick DeNatale <rick.denat...@gmail.com>
Date: Thu, 1 May 2008 21:48:29 -0500
Local: Thurs, May 1 2008 10:48 pm
Subject: Re: strip method
2008/5/1 Amasa Masiarek <a...@masiarek.com>:

k$ qri String#strip
----------------------------------------------------------- String#strip
     str.strip   => new_str
------------------------------------------------------------------------
     Returns a copy of str with leading and trailing whitespace removed.

Leading and trailing doesn't mean internal.  So:

"a1\t b1".strip #=> "a1\t b1"

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David A. Black  
View profile  
 More options May 1 2008, 10:48 pm
Newsgroups: comp.lang.ruby
From: "David A. Black" <dbl...@rubypal.com>
Date: Thu, 1 May 2008 21:48:38 -0500
Local: Thurs, May 1 2008 10:48 pm
Subject: Re: strip method
Hi --

Your expectation :-) Sorry, I couldn't resist.

strip removes space on the right and left. If you start with
"a1\t b1\n", the stripped version is "a1\t b1". If you split that on
\t, you get "a1" and " b1". At no point have you removed the middle
space.

David

--
Rails training from David A. Black and Ruby Power and Light:
   INTRO TO RAILS         June 9-12            Berlin
   ADVANCING WITH RAILS   June 16-19           Berlin
   INTRO TO RAILS         June 24-27           London (Skills Matter)
See http://www.rubypal.com for details and updates!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William James  
View profile  
 More options May 1 2008, 10:55 pm
Newsgroups: comp.lang.ruby
From: William James <w_a_x_...@yahoo.com>
Date: Thu, 1 May 2008 19:55:57 -0700 (PDT)
Local: Thurs, May 1 2008 10:55 pm
Subject: Re: strip method
On May 1, 9:39 pm, Amasa Masiarek <a...@masiarek.com> wrote:

"

a1\t     b1
a2\tb2

".strip.each{|x|
  a = x.split("\t").map{|s| s.strip }
  p a.last


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gordon Thiesfeld  
View profile  
 More options May 2 2008, 3:23 pm
Newsgroups: comp.lang.ruby
From: Gordon Thiesfeld <gthiesf...@gmail.com>
Date: Fri, 2 May 2008 14:23:18 -0500
Local: Fri, May 2 2008 3:23 pm
Subject: Re: strip method

Or split on whitespace instead of on tabs alone.

s.each{|e|
   a = e.split("\s")
   p a[1]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »