From: Matt Armstrong Date: 2002-01-08T02:01:13+09:00 Subject: Meaning of \G (was: Re: Efficient "lexing" in Ruby (maybe an RCR?)) nobu.nokada@softhome.net writes: > At Mon, 7 Jan 2002 13:18:12 +0900, > Matt Armstrong wrote: >> I liked your idea at first, but this method is actually slower in my >> case. Why? String#index with an offset does not support \A or ^ in >> the regexp. > > Use \G instead. \A always matches the beginning of the string. Yes, this works, thanks. Strangely, the "String#index with \G" version is still a little bit slower than a version that keeps chopping up the string with $POSTMATCH and using Regexp#~= with \A. I'll have to investigate. But the meaning of \G is not clear. Matz' book says "match point where last match finished" -- but for String#index that definition is confusing. Does \G for String#index just mean "anchor at beginning of offset?" -- matt