Hi, At Mon, 17 Jun 2002 11:16:02 +0900, kwatch wrote: > I wrote the following code, but I can't get an expeceted result. > ..===================== nmatch.rb ======== > str = '<html><body>hogeratta</body></html>' > while str =~ /<(\/?\w+)>/ do > print $1, "\n" > end > ..======================================== 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 -- Nobu Nakada