別のキーワード
ライブラリ
- strscan (204)
キーワード
- [] (12)
- check (12)
-
check
_ until (12) - exist? (12)
-
get
_ byte (12) - getbyte (12)
- getch (12)
- match? (12)
- matched (12)
-
matched
_ size (12) - matchedsize (12)
-
post
_ match (12) -
pre
_ match (12) - scan (12)
-
scan
_ until (12) - skip (12)
-
skip
_ until (12)
検索結果
先頭5件
-
StringScanner
# get _ byte -> String | nil (103.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... -
StringScanner
# getbyte -> String | nil (103.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... -
StringScanner
# [](nth) -> String | nil (102.0) -
前回マッチした正規表現の nth 番目のかっこに対応する部分文字列を 返します。インデックス 0 はマッチした部分全体です。前回のマッチが 失敗していると常に nil を返します。
...規表現の nth 番目のかっこに対応する部分文字列を
返します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.scan(/\w(\w)(\w*)/) # => "test"
s[0] # => "test"
s[1] # => "e"
s[2] # =>... -
StringScanner
# check(regexp) -> String | nil (102.0) -
現在位置から regexp とのマッチを試みます。 マッチに成功したらマッチした部分文字列を返します。 マッチに失敗したら nil を返します。
...ンタを進めません。
@param regexp マッチに用いる正規表現を指定します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.check(/\w+/) # => "test"
s.pos # => 0
s.matched # => "test"
s.check(/\s+/) # => nil
s.matched # => nil... -
StringScanner
# check _ until(regexp) -> String | nil (102.0) -
regexp が一致するまで文字列をスキャンします。 マッチに成功したらスキャン開始位置からマッチ部分の末尾までの部分文字列を返します。 マッチに失敗したら nil を返します。
...ンタを進めません。
@param regexp マッチに用いる正規表現を指定します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.check_until(/str/) # => "test str"
s.matched # => "str"
s.pos # => 0
s.pre_match # => "... -
StringScanner
# exist?(regexp) -> Integer | nil (102.0) -
スキャンポインタの位置から,次にマッチする文字列の末尾までの長さを返します。
...ポインタを進めません。
@param regexp マッチに用いる正規表現を指定します。
//emlist[例][ruby]{
require 'strscan'
s = StringScanner.new('test string')
s.exist?(/s/) # => 3
s.exist?(//) # => 0
s.scan(/\w+/) # => "test"
s.exist?(/s/) # => 2
s.exist?(/e/) # => nil
//}... -
StringScanner
# getch -> String | nil (102.0) -
一文字スキャンして文字列で返します。 スキャンポインタをその後ろに進めます。 スキャンポインタが文字列の末尾を指すならnilを返します。
...定義は、与えた文字列のエンコードに依存します。
//emlist[例][ruby]{
require 'strscan'
utf8 = "\u{308B 3073 3044}"
s = StringScanner.new(utf8.encode("UTF-8"))
p s.getch # => "る"
p s.getch # => "び"
p s.getch... -
StringScanner
# match?(regexp) -> Integer | nil (102.0) -
スキャンポインタの地点だけで regexp と文字列のマッチを試します。 マッチしたら、スキャンポインタは進めずにマッチした 部分文字列の長さを返します。マッチしなかったら nil を 返します。
..."\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]{
require 'strscan'
s = StringScanner.new('test string')
p s.ma... -
StringScanner
# matched -> String | nil (102.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.sc...