るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< < ... 2 3 4 5 6 > >>

StringScanner#bol? -> bool (24038.0)

スキャンポインタが行頭を指しているなら true を、 行頭以外を指しているなら false を返します。

...ことです。
文字列末尾は必ずしも行頭ではありません。

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

s = StringScanner.new("test\nstring")
s.bol? # => true
s.scan(/\w+/)
s.bol? # => false
s.scan(/\n/)
s.bol? # => true
s.scan(/\w+/)
s.bol? # => false
//}...

StringScanner#clear -> self (24038.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 を使ってください。...

StringScanner#match?(regexp) -> Integer | nil (24038.0)

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

...list[][ruby]{
require '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]{
req...
...uire '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 (24038.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? -> bool (24038.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#rest -> String (24038.0)

文字列の残り (rest) を返します。 具体的には、スキャンポインタが指す位置からの文字列を返します。

...列 ("") を返します。

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

s = StringScanner.new('test string')
s.rest # => "test string"
s.scan(/\w+/) # => "test"
s.rest # => " string"
s.scan(/\s+/) # => " "
s.rest # => "string"
s.scan(/\w+/) # => "string"
s.rest # => "...

StringScanner#terminate -> self (24038.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 を使ってください。...

StringScanner#charpos -> Integer (24032.0)

現在のスキャンポインタのインデックスを文字単位で返します。

...キャンポインタのインデックスを文字単位で返します。

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

s = StringScanner.new("abcädeföghi")
s.charpos # => 0
s.scan_until(/ä/) # => "abcä"
s.pos # => 5
s.charpos # => 4
//}

@see StringScanner#pos...

StringScanner#get_byte -> String | nil (24032.0)

1 バイトスキャンして文字列で返します。 スキャンポインタをその後ろに進めます。 スキャンポインタが文字列の末尾を指すなら nil を返します。

...すなら nil を返します。

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

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

utf8 = "\u{308B 3073 3044}"
s = StringScanner.new(utf8.encode("EUC-JP"))
p s.g...
<< < ... 2 3 4 5 6 > >>