Hi,

At Tue, 18 Jun 2002 04:37:11 +0900,
kwatch wrote:
> You showed three ways to make my desire.
> Which is the fastest?  Please tell me if you know it.

I ordered in faster first.

String#index needs to adjust multibyte alignment each time, and
it's slow in 1.6.  And the last example need to create new
Regexps each time.

And errata.
> pos = 0
> while pos = str.index(/<(\/?\w+)>/, pos) do
  while str.index(/<(\/?\w+)>/, pos) do
>   print $1, "\n"
>   pos += $1.size
    pos = $~.end(0)
> end

> pos = 0
> while str =~ /\A.{#{pos}}.*?<(\/?\w+)>/ do
  while str =~ /\A.{#{pos}}.*?<(\/?\w+)>/m do
>   print $1, "\n"
>   pos = $&.size
    pos = $~.end(0)
> end


-- 
Nobu Nakada