Deletes every character which is not in the ranges a-z and A-Z in the
string variable line. Ie.
irb(main):001:0> line = "abZdF.A4d"
=> "abZdF.A4d"
irb(main):002:0> line.tr!("^a-zA-Z", "")
=> "abZdFAd"
irb(main):003:0>
···
On Mon, 20 Dec 2004 17:20:07 +0900 Giovanni Intini <intinig@gmail.com> wrote:
On Mon, 20 Dec 2004 10:36:18 +0900, James Edward Gray II > <james@grayproductions.net> wrote:
> Here's my solution. It doesn't really have any clever
> optimizations, but it runs in seconds.
> line.tr!("^a-zA-Z", "")
Can you explain this line?
--
\ Thomas Leitner -- thomas [underscore] leitner [at] gmx [dot] at
/ "Life is what happens to you while you're busy making other plans"
thanks for the tip. I always did a match to /\w/ instead of doing like you did.
···
On Mon, 20 Dec 2004 19:32:08 +0900, Thomas Leitner <t_leitner@gmx.at> wrote:
On Mon, 20 Dec 2004 17:20:07 +0900 > Giovanni Intini <intinig@gmail.com> wrote:
> On Mon, 20 Dec 2004 10:36:18 +0900, James Edward Gray II > > <james@grayproductions.net> wrote:
> > Here's my solution. It doesn't really have any clever
> > optimizations, but it runs in seconds.
>
> > line.tr!("^a-zA-Z", "")
>
> Can you explain this line?
>
>
Deletes every character which is not in the ranges a-z and A-Z in the
string variable line. Ie.
irb(main):001:0> line = "abZdF.A4d"
=> "abZdF.A4d"
irb(main):002:0> line.tr!("^a-zA-Z", "")
=> "abZdFAd"
irb(main):003:0>
--
>\ Thomas Leitner -- thomas [underscore] leitner [at] gmx [dot] at
>>
>/ "Life is what happens to you while you're busy making other plans"