るりまサーチ

最速Rubyリファレンスマニュアル検索!
99件ヒット [1-99件を表示] (0.112秒)
トップページ > クエリ:-[x] > クエリ:r[x] > クエリ:at[x] > クエリ:l[x] > ライブラリ:strscan[x]

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. fileutils cp_r

クラス

キーワード

検索結果

StringScanner#pre_match -> String | nil (12402.0)

前回マッチを行った文字列のうち、マッチしたところよりも前の 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。

...il
返します。

//emlist[例][ruby]{
r
equire '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#terminate -> self (12402.0)

スキャンポインタを文字列末尾後まで進め、マッチ記録を捨てます。

...@return self を返します。

pos = self.string.size と同じ動作です。

//emlist[例][ruby]{
r
equire '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 を使ってください。...

StringScanner#matched_size -> Integer | nil (9414.0)

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

...nil を返します。

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

//emlist[][ruby]{
r
equire '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]{
r
equire '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 (9408.0)

スキャンポインタの地点だけで regexp と文字列のマッチを試します。 マッチしたら、スキャンポインタは進めずにマッチした 部分文字列の長さを返します。マッチしなかったら nil を 返します。

...スキャンポインタの地点だけで regexp と文字列のマッチを試します。
マッチしたら、スキャンポインタは進めずにマッチした
部分文字列の長さを返します。マッチしなかったら nil
返します。

マッチしたサイズは文字単...
...mlist[][ruby]{
r
equire 'strscan'
def case1(encode)
utf8 = "\u{308B 3073 3044}"
s = StringScanner.new(utf8.encode(encode))
s.match?(/#{"\u{308B}".encode(encode)}/)
end

p case1("EUC-JP") #=> 2
//}

@param regexp マッチに用いる正規表現を指定します。

//emlist[例][ruby]{
r
e...
...quire 'strscan'

s = StringScanner.new('test string')
p s.match?(/\w+/) #=> 4
p s.match?(/\w+/) #=> 4
p s.match?(/\s+/) #=> nil
//}...

StringScanner#matched -> String | nil (9402.0)

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

...に失敗していると nil を返します。

//emlist[例][ruby]{
r
equire '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#matchedsize -> Integer | nil (9402.0)

StringScanner#matched_size と同じです。

...StringScanner#matched_size と同じです。

このメソッドは は将来のバージョンで削除される予定です。
代わりに StringScanner#matched_size を使ってください。

@see StringScanner#matched_size...

StringScanner#post_match -> String | nil (9402.0)

前回マッチを行った文字列のうち、マッチしたところよりも後ろの 部分文字列を返します。前回のマッチが失敗していると常に nil を 返します。

...il
返します。

//emlist[例][ruby]{
r
equire '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.scan(/\w+/) # => "stri...
...ng"
s.post_match # => ""
s.scan(/\w+/) # => nil
s.post_match # => nil
//}...

StringScanner#matched? -> bool (9302.0)

前回のマッチが成功していたら true を、 失敗していたら false を返します。

...ら true を、
失敗していたら false を返します。

//emlist[例][ruby]{
r
equire '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#concat(str) -> self (6402.0)

操作対象の文字列に対し str を破壊的に連結します。 マッチ記録は変更されません。

...対し str を破壊的に連結します。
マッチ記録は変更されません。

selfを返します。

@param str 操作対象の文字列に対し str を破壊的に連結します。

//emlist[例][ruby]{
r
equire 'strscan'

s = StringScanner.new('test') # => #<StringScanner 0/4 @ "test"...
..."est"
s << ' string' # => #<StringScanner 4/11 "test" @ " stri...">
s[0] # => "test"
s[1] # => "est"
s.scan(/\s+/) # => " "
s.scan(/\w+/) # => "string"
//}

この操作は StringScanner.new に渡し...
...た文字列にも影響することがあります。

//emlist[例][ruby]{
r
equire 'strscan'

str = 'test'
s = StringScanner.new(str) # => #<StringScanner 0/4 @ "test">
s << ' string' # => #<StringScanner 0/11 @ "test ...">
str # => "test string"
//}...