class String # Like #scan but returns MatchData ($~) rather # then matched string ($&). # # require 'facet/string/mscan' # def mscan(re) #:yield: if block_given? scan(re) { yield($~) } else m = [] scan(re) { m << $~ } m end end end