るりまサーチ

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

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub!

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 ... > >>

StringScanner#matched -> String | nil (12316.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#concat(str) -> self (12150.0)

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

...変更されません。

selfを返します。

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

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

s = StringScanner.new('test') # => #<StringScanner 0/4 @ "test">
s.scan(/\w(\w*)/) # => "test"
s[0]...
...=> "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]{
require 'strscan'

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

StringScanner#search_full(regexp, s, f) -> object (12138.0)

regexp で指定された正規表現とマッチするまで文字列をスキャンします。

...ンポインタを進めます。
* s が false ならばスキャンポインタを進めません。
* f が true ならばスキャン開始位置からマッチした部分の末尾までの部分文字列を返します。
* f が false ならばスキャン開始位置からマッ...
...* search_full(regexp, true, true) は StringScanner#scan_until と同等。
* search_full(regexp, true, false) は StringScanner#skip_until と同等。
* search_full(regexp, false, true) は StringScanner#check_until と同等。
* search_full(regexp, false, false) は StringScanner#exi...
...@param regexp マッチに用いる正規表現を指定します。

@param s true ならばスキャンポインタを進めます。
false ならばスキャンポインタを進めません。

@param f true ならばマッチした部分文字列を返します。
false な...

StringScanner#clear -> self (12126.0)

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

...elf を返します。

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

//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#terminate -> self (12126.0)

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

...elf を返します。

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

//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 (12114.0)

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

...can'
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]{
require 'strscan'

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

StringScanner#matched? -> bool (12114.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#matched_size -> Integer | nil (12114.0)

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

...'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#charpos -> Integer (12102.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...
<< < 1 2 3 4 ... > >>