[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: Wybo Dekker <wybo () servalys ! nl>
Date: 2005-07-29 13:01:32
Message-ID: 42EA2887.2070404 () servalys ! nl
[Download RAW message or body]
francisrammeloo@hotmail.com wrote:
>Hi all,
>
>I'm having some trouble finding an elegant way of removing a part of a
>string based on an pattern.
>
>Suppose I want to chop off the "Begin" in the string "BeginCaption".
>
>
irb(main):001:0> w='BeginCaption'
=> "BeginCaption"
irb(main):002:0> w.slice!(/^Begin/)
=> "Begin"
irb(main):003:0> w
=> "Caption"
--
Wybo
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic