以下の内容はhttps://tbpgr.hatenablog.com/entry/20140609/1402317042より取得しました。


Ruby | MatchData | end

概要

MatchData#end(n) -> Fixnum | nil

詳細

n 番目の部分文字列終端のオフセットを返します。
0 はマッチ全体を意味します。
n 番目の部分文字列がマッチしていなければ nil を返します。

サンプルコード
require 'tbpgr_utils'

"hogehigehage" =~ /(h\wge)(h\wge)(h\wge)/

bulk_puts_eval binding, <<-EOS
$~.size
$~.end 0
$~.end 1
$~.end 2
$~.end 3
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils

出力

$~.size  # => 4
$~.end 0 # => 12
$~.end 1 # => 4
$~.end 2 # => 8
$~.end 3 # => 12



以上の内容はhttps://tbpgr.hatenablog.com/entry/20140609/1402317042より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14