るりまサーチ (Ruby 2.6.0)

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

別のキーワード

  1. string encode
  2. _builtin encode
  3. string encode!
  4. uri encode_www_form
  5. base64 encode64

ライブラリ

クラス

検索結果

StringScanner#matched_size -> Integer | nil (63487.0)

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

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

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

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

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

p run("UTF-8") #=> 3
p...