検索結果
-
MatchData
# bytebegin(n) -> Integer | nil (24375.0) -
n 番目の部分文字列先頭のバイトオフセットを返します。
...バイトオフセットを返します。
@param n 部分文字列を指定する数値。
@param name 名前付きキャプチャを指定する文字列またはシンボル。
@raise IndexError 範囲外の n を指定した場合に発生します。
@raise IndexError 正規表現中で定義......。
//emlist[例][ruby]{
/(c).*(いう).*(e.*)/ =~ 'abcあいうdef'
p $~ # => #<MatchData "cあいうdef" 1:"c" 2:"いう" 3:"ef">
p $~.bytebegin(0) # => 2
p $~.bytebegin(1) # => 2
p $~.bytebegin(2) # => 6
p $~.bytebegin(3) # => 13
p $~.bytebegin(4) # => index 4 out of matches (IndexE......rror)
//}
//emlist[シンボルを指定する例][ruby]{
/(?<key>\S+):\s*(?<value>\S+)/ =~ "name: ruby"
$~ # => #<MatchData "name: ruby" key:"name" value:"ruby">
$~.bytebegin(:key) # => 0
$~.bytebegin(:value) # => 6
$~.bytebegin(:foo) # => undefined group name reference: foo... -
MatchData
# bytebegin(name) -> Integer | nil (24375.0) -
n 番目の部分文字列先頭のバイトオフセットを返します。
...バイトオフセットを返します。
@param n 部分文字列を指定する数値。
@param name 名前付きキャプチャを指定する文字列またはシンボル。
@raise IndexError 範囲外の n を指定した場合に発生します。
@raise IndexError 正規表現中で定義......。
//emlist[例][ruby]{
/(c).*(いう).*(e.*)/ =~ 'abcあいうdef'
p $~ # => #<MatchData "cあいうdef" 1:"c" 2:"いう" 3:"ef">
p $~.bytebegin(0) # => 2
p $~.bytebegin(1) # => 2
p $~.bytebegin(2) # => 6
p $~.bytebegin(3) # => 13
p $~.bytebegin(4) # => index 4 out of matches (IndexE......rror)
//}
//emlist[シンボルを指定する例][ruby]{
/(?<key>\S+):\s*(?<value>\S+)/ =~ "name: ruby"
$~ # => #<MatchData "name: ruby" key:"name" value:"ruby">
$~.bytebegin(:key) # => 0
$~.bytebegin(:value) # => 6
$~.bytebegin(:foo) # => undefined group name reference: foo...