るりまサーチ

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

別のキーワード

  1. string scan
  2. _builtin scan
  3. c scan
  4. rd scan
  5. strscan scan

ライブラリ

クラス

検索結果

StringScanner#[](nth) -> String | nil (21125.0)

前回マッチした正規表現の nth 番目のかっこに対応する部分文字列を 返します。インデックス 0 はマッチした部分全体です。前回のマッチが 失敗していると常に nil を返します。

...返します。


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

s = StringScanner.new('test string')
s.scan(/\w(\w)(\w*)/) # => "test"
s[0] # => "test"
s[1] # => "e"
s[2] # => "st"
s.scan(/\w+/) # => nil
s[0] # => nil
s[1...
...] # => nil
s[2] # => nil
s.scan(/\s+/) # => " "
s[0] # => " "
s[1] # => nil
s[2] # => nil
s.scan(/\w(\w)(\w*)/) # => "string"
s[0] # => "string"
s[1] # => "t"
s[2]...