るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.087秒)
トップページ > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:i[x] > クエリ:string[x] > クエリ:shift[x] > クラス:StringScanner[x]

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. _builtin i
  5. _builtin $-i

ライブラリ

検索結果

StringScanner#matched_size -> Integer | nil (9126.0)

前回マッチした部分文字列の長さを返します。 前回マッチに失敗していたら nil を返します。

...回マッチに失敗していたら nil を返します。

マッチしたサイズは文字単位でなくバイト単位となります。

//emlist[][ruby]{
require 'strscan'

def run(encode)
utf8 = "\u{308B 3073 3044}" # るびい
s = StringScanner.new(utf8.encode(encode))
s.scan(/#{"\u{...
...tched_size
end

p run("UTF-8") #=> 3
p run("EUC-JP") #=> 2
p run("Shift_Jis") #=> 2

//}

//emlist[例][ruby]{
require 'strscan'

s = StringScanner.new('test string')
s.matched_size # => nil
s.scan(/\w+/) # => "test"
s.matched_size # => 4
s.scan(/\w+/) # => nil
s.matched_size # => nil
//}...