[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

strip method

Adam Masiarek

5/2/2008 2:39:00 AM

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-....

10 Answers

Adam Masiarek

5/2/2008 2:43:00 AM

0

This works fine ...

s.each{|e|
a = e.gsub(' ','').split("\t")
p a[1]
}
--
Posted via http://www.ruby-....

Rick DeNatale

5/2/2008 2:48:00 AM

0

2008/5/1 Amasa Masiarek <adam@masiarek.com>:
> 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?

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.denh...

David A. Black

5/2/2008 2:49:00 AM

0

Hi --

On Fri, 2 May 2008, Amasa Masiarek wrote:

> 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?

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.r... for details and updates!

William James

5/2/2008 2:56:00 AM

0

On May 1, 9:39 pm, Amasa Masiarek <a...@masiarek.com> wrote:
> 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 viahttp://www.ruby-....


"

a1\t b1
a2\tb2


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

Gordon Thiesfeld

5/2/2008 7:23:00 PM

0

On Thu, May 1, 2008 at 10:00 PM, William James <w_a_x_man@yahoo.com> wrote:
> On May 1, 9:39 pm, Amasa Masiarek <a...@masiarek.com> wrote:
> > 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 viahttp://www.ruby-....
>
>
> "
>
> a1\t b1
> a2\tb2
>
>
> ".strip.each{|x|
> a = x.split("\t").map{|s| s.strip }
> p a.last
> }
>
>

Or split on whitespace instead of on tabs alone.

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

WangoTango

10/28/2009 3:12:00 PM

0

In article <4AE7E1E9.31BF9A68@mchsi.com>, jwarner@mchsi.com says...
>
>
> AndScene wrote:
>
> > > How much was she paid to do this???????
> >
> > It's sad that she can be bought like this. Whatever happened to
> > standing up on principle? She has kids of her own now, I can't help
> > but wonder if some old pervert raped her 13 year old girl if she'd be
> > as forgiving.
> >
> > She really should just shut up at this point.
>
> and people wonder WHY prosecuters now feel victims
> need tobe taken out of the link and prosecutions need
> to procede on their own merits (of Law). In that case
> this victim would have nothing to say in the matter and
> Ratsky could not squirm out from under his mess one
> more time. Yuppie Justice really doesnt werk? ! ?

It doesn't matter what SHE wants, he is guilty of fleeing, which has
nothing to do with the original charges.

Speeders & Drunk Drivers are MURDERERS

10/28/2009 4:15:00 PM

0

WangoTango <Asgard24@mindspring.com> wrote in
news:MPG.255229594136663098ad09@news.east.earthlink.net:

> In article <4AE7E1E9.31BF9A68@mchsi.com>, jwarner@mchsi.com says...
>>
>>
>> AndScene wrote:
>>
>> > > How much was she paid to do this???????
>> >
>> > It's sad that she can be bought like this. Whatever happened to
>> > standing up on principle? She has kids of her own now, I can't help
>> > but wonder if some old pervert raped her 13 year old girl if she'd be
>> > as forgiving.
>> >
>> > She really should just shut up at this point.
>>
>> and people wonder WHY prosecuters now feel victims
>> need tobe taken out of the link and prosecutions need
>> to procede on their own merits (of Law). In that case
>> this victim would have nothing to say in the matter and
>> Ratsky could not squirm out from under his mess one
>> more time. Yuppie Justice really doesnt werk? ! ?
>
> It doesn't matter what SHE wants, he is guilty of fleeing, which has
> nothing to do with the original charges.
>
>

He can still be sentenced and punished for the original crime.

Beam Me Up Scotty

10/28/2009 4:32:00 PM

0

Speeders & Drunk Drivers are MURDERERS wrote:
> WangoTango <Asgard24@mindspring.com> wrote in
> news:MPG.255229594136663098ad09@news.east.earthlink.net:
>
>> In article <4AE7E1E9.31BF9A68@mchsi.com>, jwarner@mchsi.com says...
>>>
>>> AndScene wrote:
>>>
>>>>> How much was she paid to do this???????
>>>> It's sad that she can be bought like this. Whatever happened to
>>>> standing up on principle? She has kids of her own now, I can't help
>>>> but wonder if some old pervert raped her 13 year old girl if she'd be
>>>> as forgiving.
>>>>
>>>> She really should just shut up at this point.
>>> and people wonder WHY prosecuters now feel victims
>>> need tobe taken out of the link and prosecutions need
>>> to procede on their own merits (of Law). In that case
>>> this victim would have nothing to say in the matter and
>>> Ratsky could not squirm out from under his mess one
>>> more time. Yuppie Justice really doesnt werk? ! ?
>> It doesn't matter what SHE wants, he is guilty of fleeing, which has
>> nothing to do with the original charges.
>>
>>
>
> He can still be sentenced and punished for the original crime.


He compounded the crime with new crimes against the state? Good point.

So even if the rape is dropped he still is guilty of crimes of fleeing
justice. That's probably good for a few years, and there is no statute
of limitations for fleeing the law.


comadrejo

10/28/2009 4:34:00 PM

0

In article
<878134ed-a7aa-4333-bb12-f391b3af7a2a@s15g2000yqs.googlegroups.com>,
Yup <johnnycat@hotmail.com> wrote:

> On Oct 28, 12:14?pm, "Speeders & Drunk Drivers are MURDERERS"
> <xeton2...@yahoo.com> wrote:
> >
> >
> >
> > > In article <4AE7E1E9.31BF9...@mchsi.com>, jwar...@mchsi.com says...
> >
> > >> AndScene wrote:
> >
> > >> > > How much was she paid to do this???????
> >
> > >> > It's sad that she can be bought like this. Whatever happened to
> > >> > standing up on principle? She has kids of her own now, I can't help
> > >> > but wonder if some old pervert raped her 13 year old girl if she'd be
> > >> > as forgiving.
> >
> > >> > She really should just shut up at this point.
> >
> > >> and people wonder WHY prosecuters now feel victims
> > >> need tobe taken out of the link and prosecutions need
> > >> to procede on their own merits (of Law). In that case
> > >> this victim would have nothing to say in the matter and
> > >> Ratsky could not squirm out from under his mess one
> > >> more time. Yuppie Justice really doesnt werk? ! ?
> >
> > > It doesn't matter what SHE wants, he is guilty of fleeing, which has
> > > nothing to do with the original charges.
> >
> > He can still be sentenced and punished ?for the original crime.
> >
> >
>
>
> He should get a new trial due to the obvious judicial and
> prosecutorial misconduct that occurred after the original trial -
> prior to his failure to show up for sentencing.

Yes, he should get a new trial in the land where people can't even
read up about this case.

There was no trial. Polanski pled guilty to one felony charge of
statutory rape in a plea deal. He was facing six felonies, including
rape, child molestation, sodomy and giving alcohol and drugs to a minor.


Once, Polanski pled guilty, it is very difficult to withdraw the plea,
unless he was going to have the plea deal thrown out anyway and get
charged with the five other charges...

I think people should remember that documentaries have to follow
guidelines, but they can be easily manipulated and manipulative, like
"Roman Polanksi: Wanted and Desire".

SaPeIsMa

10/30/2009 1:11:00 PM

0


"Cori" <cmashieldscapting@hotmail.com> wrote in message
news:b366b38a-473b-48db-8e15-0ae98f1b7392@a37g2000prf.googlegroups.com...
> So it's the guilty plea which makes the difference here? Otherwise,
> what is the statute of limitations on such a crime? In a case in
> which a young victim blew the whistle on a corrupt sports coach,
> others he molested decades before came forward and were told their
> cases could not be considered as the statute of limitations had run
> out.
>
> Cori

There is NO statute of limitations AFTER you plead guilty
The Statute of limitation applies to prosecution BEFORE you plead guilty or
are judged guilty