From: kwatch@... (kwatch) Date: 2002-06-18T04:37:11+09:00 Subject: Re: Q: n-times matching Thank you very much, Nobu. You showed three ways to make my desire. Which is the fastest? Please tell me if you know it. regards kwatch nobu.nokada@softhome.net wrote in message news:<200206170318.g5H3Ib211677@sharui.nakada.kanuma.tochigi.jp>... > > It matches at same point everytime. > > str.scan(/<(\/?\w+)>/) do > print $1, "\n" > end > > pos = 0 > while pos = str.index(/<(\/?\w+)>/, pos) do > print $1, "\n" > pos += $1.size > end > > pos = 0 > while str =~ /\A.{#{pos}}.*?<(\/?\w+)>/ do > print $1, "\n" > pos = $&.size > end