88件ヒット
[1-88件を表示]
(0.031秒)
クラス
- StringScanner (88)
キーワード
- match? (11)
- matched (11)
- matched? (11)
-
matched
_ size (11) - matchedsize (11)
-
post
_ match (11) -
pre
_ match (11) - terminate (11)
検索結果
先頭5件
-
StringScanner
# post _ match -> String | nil (6249.0) -
前回マッチを行った文字列のうち、マッチしたところよりも後ろの 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。
...ていると常に nil を
返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.post_match # => nil
s.scan(/\w+/) # => "test"
s.post_match # => " string"
s.scan(/\w+/) # => nil
s.post_match # => nil
s.scan(/\s+/) # => " "
s.post_match # => "string"
s.sc......an(/\w+/) # => "string"
s.post_match # => ""
s.scan(/\w+/) # => nil
s.post_match # => nil
//}... -
StringScanner
# pre _ match -> String | nil (6249.0) -
前回マッチを行った文字列のうち、マッチしたところよりも前の 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。
...敗していると常に nil を
返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.pre_match # => nil
s.scan(/\w+/) # => "test"
s.pre_match # => ""
s.scan(/\w+/) # => nil
s.pre_match # => nil
s.scan(/\s+/) # => " "
s.pre_match # => "test"
s.scan(....../\w+/) # => "string"
s.pre_match # => "test "
s.scan(/\w+/) # => nil
s.pre_match # => nil
//}... -
StringScanner
# matched -> String | nil (6237.0) -
前回マッチした部分文字列を返します。 前回のマッチに失敗していると nil を返します。
...に失敗していると nil を返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.matched # => nil
s.scan(/\w+/) # => "test"
s.matched # => "test"
s.scan(/\w+/) # => nil
s.matched # => nil
s.scan(/\s+/) # => " "
s.matched # => " "
//}... -
StringScanner
# matched _ size -> Integer | nil (6237.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 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
//}... -
StringScanner
# match?(regexp) -> Integer | nil (6225.0) -
スキャンポインタの地点だけで regexp と文字列のマッチを試します。 マッチしたら、スキャンポインタは進めずにマッチした 部分文字列の長さを返します。マッチしなかったら nil を 返します。
...マッチしなかったら nil を
返します。
マッチしたサイズは文字単位でなくバイト単位となります。
//emlist[][ruby]{
require 'strscan'
def case1(encode)
utf8 = "\u{308B 3073 3044}"
s = StringScanner.new(utf8.encode(encode))
s.match?(/#{"\u{308B}".encode(enc......ode)}/)
end
p case1("EUC-JP") #=> 2
//}
@param regexp マッチに用いる正規表現を指定します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
p s.match?(/\w+/) #=> 4
p s.match?(/\w+/) #=> 4
p s.match?(/\s+/) #=> nil
//}... -
StringScanner
# matchedsize -> Integer | nil (6203.0) -
StringScanner#matched_size と同じです。
...StringScanner#matched_size と同じです。
このメソッドは は将来のバージョンで削除される予定です。
代わりに StringScanner#matched_size を使ってください。
@see StringScanner#matched_size... -
StringScanner
# matched? -> bool (6108.0) -
前回のマッチが成功していたら true を、 失敗していたら false を返します。
...失敗していたら false を返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.matched? # => false
s.scan(/\w+/) # => "test"
s.matched? # => true
s.scan(/\w+/) # => nil
s.matched? # => false
s.scan(/\s+/) # => " "
s.matched? # => true
//}... -
StringScanner
# terminate -> self (3114.0) -
スキャンポインタを文字列末尾後まで進め、マッチ記録を捨てます。
...動作です。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.scan(/\w+/) # => "test"
s.matched # => "test"
s.pos # => 4
s[0] # => "test"
s.terminate
s.matched # => nil
s[0] # => nil
s.pos # => 11
//}
StringScanner#clear......は将来のバージョンで削除される予定です。
代わりに StringScanner#terminate を使ってください。...