[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: Chopping the beginning of a string elegantly
From: David Vallner <david () vallner ! net>
Date: 2005-07-29 20:14:04
Message-ID: 42EA8DC6.8030604 () vallner ! net
[Download RAW message or body]
William James wrote:
>francisrammeloo@hotmail.com wrote:
>
>
>>Thanks all,
>>
>>I eventually used this
>>
>>thePane = line.scan(/Begin\w+/)[0].sub(/Begin/, "")
>>
>>where line looks like this:
>>BeginCaption 0, 20, 66, ..
>>
>>It looks a little better but still not very elegant. Is it possible to
>>make it even still shorter?
>>
>>
>
>line[/Begin(\w+)/]; thePane = $1
>
>
>
>
thePane = line.sub(/Begin/, "") should work. Look, mom, nothing gets
clobbered in place, no magic globals are used.
Just my 2 cents...
David
(as likkle a newbie as they get)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic