Re: Regular Expression question
- From: "Robert Dober" <robert.dober@xxxxxxxxx>
- Date: Sat, 30 Jun 2007 16:32:51 +0900
On 6/30/07, Peter Seebach <seebs@xxxxxxxxx> wrote:
In message <0df4a451b19810ff6e06f11725324591@xxxxxxxxxxxxxx>, Al Cholic writes:Maybe it would not hurt to add a little clarification, albeit the fact
>Im working with regular expressions and I cant quite understand how the
>"13" is extracted from the string.
>Here is the irb output:
>irb(main):005:0> "(13)"[1..-2].to_i
>=> 13
>I dont understadn how the [1..-2] parameter removes the parenthases from
>the string.
"(13)"[0] = "("
"(13)"[1] = "1"
"(13)"[2] = "3"
"(13)"[3] = ")"
"(13)"[-1] = ")"
"(13)"[-2] = "3"
"(13)"[-3] = "1"
"(13)"[-4] = "("
that your didactic simplification has worked very well :). Especially
as this concerns a FAQ
In reality
"(13)"[0] => ?( which equals 40
and
"(13)"[0..0] => "("
Cheers
Robert
--
I always knew that one day Smalltalk would replace Java.
I just didn't know it would be called Ruby
-- Kent Beck
.
- Follow-Ups:
- Re: Regular Expression question
- From: Peter Seebach
- Re: Regular Expression question
- References:
- Regular Expression question
- From: Al Cholic
- Re: Regular Expression question
- From: Peter Seebach
- Regular Expression question
- Prev by Date: Re: [ANN] webgen 0.4.5
- Next by Date: Re: Regular Expression question
- Previous by thread: Re: Regular Expression question
- Next by thread: Re: Regular Expression question
- Index(es):
Relevant Pages
|