[#3228] Core support for Gems, and namespace — "Luke A. Kanies" <luke@...>

Hi all,

21 messages 2004/07/27
[#3230] Re: Core support for Gems, and namespace — Austin Ziegler <halostatue@...> 2004/07/27

On Tue, 27 Jul 2004 11:39:08 +0900, Luke A. Kanies <luke@madstop.com> wrote:

[#3234] Re: Core support for Gems, and namespace — "Luke A. Kanies" <luke@...> 2004/07/27

On Tue, 27 Jul 2004, Austin Ziegler wrote:

[#3238] Re: Core support for Gems, and namespace — Austin Ziegler <halostatue@...> 2004/07/27

On Wed, 28 Jul 2004 00:14:29 +0900, Luke A. Kanies <luke@madstop.com> wrote:

Re: Trying to understand \G

From: Dave Thomas <dave@...>
Date: 2004-07-27 19:55:08 UTC
List: ruby-core #3239
On Jul 27, 2004, at 10:34, daz wrote:
> Below, Nobu's example [core:3203] works for \G whereas (substituting
> \A for \G in PATT) it confirms that the start of string is at offset
> zero and none other.
>
>    words = 'dog horse cat rabbit pig sheep'
>    PATT = /\G\w+/
>
>    last = 0
>    while index = words.index(PATT, last)
>      puts index
>      puts $&
>      last = Regexp.last_match.end(0) + 1
>    end

Ah, and now I can see a reason for it---something like this:

words = 'ant bee cat, dog elf fox'
last = 0
while index = words.index(/\w+/, last)
   puts index, $&.inspect
   last = Regexp.last_match.end(0)
   # match comma, but only if next character
   last += 1 if words.index(/\G,/, last)
   last += 1  # skip space
end


Cheers

Dave


In This Thread

Prev Next