るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.016秒)

別のキーワード

  1. matchdata []
  2. matchdata offset
  3. _builtin matchdata
  4. matchdata size
  5. matchdata end

ライブラリ

クラス

キーワード

検索結果

MatchData#size -> Integer (36124.0)

部分文字列の数を返します(self.to_a.size と同じです)。

...部分文字列の数を返します(self.to_a.size と同じです)。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.size # => 4
//}...

MatchData#length -> Integer (21024.0)

部分文字列の数を返します(self.to_a.size と同じです)。

...部分文字列の数を返します(self.to_a.size と同じです)。

//emlist[例][ruby]{
/(foo)(bar)(BAZ)?/ =~ "foobarbaz"
p $~.size # => 4
//}...

String#byterindex(pattern, offset = self.bytesize) -> Integer | nil (119.0)

文字列のバイト単位のインデックス offset から左に向かって pattern を探索します。 最初に見つかった部分文字列の左端のバイト単位のインデックスを返します。 見つからなければ nil を返します。

...2
$~ #=> #<MatchData "o">

# 最長にするには否定戻り読み(negative look-behind)と組み合わせる
'foo'.byterindex(/(?<!o)o+/) # => 1
$~ #=> #<MatchData "oo">

# またはbyteindexを否定先読み(negative look-ahead)
'foo'.byteindex(/o+(?!.*o)/) # => 1
$~ #=> #<MatchData "oo">

'fo...