Issue #5606 has been updated by mame (Yusuke Endoh).

Status changed from Open to Feedback

???????????

2011?11???10???17:19 Tomoaki Nishiyama <tomoakin / staff.kanazawa-u.ac.jp>:
> String#scan ???????????????????
>
>  longstring.scan(regex) do |matchstr|
>    m=Regexp.last_match
>    ...
>    puts "#{m.begin(0)}-#{m.end(0)-1} some other info"
>  end
>
> ???????確?????????????????????????????????????????????????????????????????

$~ ???使?????????????????

  longstring.scan(regex) do
    ...
    puts "#{$~.begin(0)}-#{$~.end(0)-1} some other info"
  end


????????????????????????????????????????????????????????????????
?????????????????????????????????String#scan ??? String#gsub ???
??????????????????????????????? (#546) ???????話???????????
?????????話????????????????????????????????????????
???????????????????????????????????????????????????????????


????????????????????????????示?????????????????


??????????????????????

  offset = m.end(0)

?????

  offset = m.begin(0)+1

???????????????????????????????

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Feature #5606: String#each_match(regexp)
https://bugs.ruby-lang.org/issues/5606#change-25254

Author: tomoakin (Tomoaki Nishiyama)
Status: Feedback
Priority: Low
Assignee: 
Category: 
Target version: 


??????????正覨?????????????????offset???????????????????????????
??????????欲????????????????????
????????索????????1996?
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/1206
??????????話?????????
http://stackoverflow.com/questions/6804557/how-do-i-get-the-match-data-for-all-occurrences-of-a-ruby-regular-expression-in
????????????????????????????????????????????????????????????

class String
  def each_match(pattern, offset=0)
    while(m = self.match(pattern, offset))
      offset = m.begin(0)+1
      yield m
    end
  end
end

??????????????????????
対称????Regexp#each_match????????????????


-- 
http://bugs.ruby-lang.org/