るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

StringIO#each(rs = $/) -> Enumerator (21117.0)

自身から 1 行ずつ読み込み、それを引数として与えられたブロックを実行します。

...連続する改行を行の区切りとみなします(パラグラフモード)。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require "stringio"
a = StringIO.new("hoge\nfoo\n")
a.each{|l| p l }
#=> "hoge\n"
# "foo\n"
//}

@see $/
@see IO#each_line...

StringIO#each(rs = $/) {|line| ... } -> self (21117.0)

自身から 1 行ずつ読み込み、それを引数として与えられたブロックを実行します。

...連続する改行を行の区切りとみなします(パラグラフモード)。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require "stringio"
a = StringIO.new("hoge\nfoo\n")
a.each{|l| p l }
#=> "hoge\n"
# "foo\n"
//}

@see $/
@see IO#each_line...

String#each_grapheme_cluster -> Enumerator (15133.0)

文字列の書記素クラスタに対して繰り返します。

...

String
#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#g...

String#each_grapheme_cluster {|grapheme_cluster| block } -> self (15133.0)

文字列の書記素クラスタに対して繰り返します。

...

String
#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#g...

String#each_byte -> Enumerator (15121.0)

文字列の各バイトに対して繰り返します。

...文字列の各バイトに対して繰り返します。

//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114

"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}

@see String#bytes...

絞り込み条件を変える

String#each_byte {|byte| ... } -> self (15121.0)

文字列の各バイトに対して繰り返します。

...文字列の各バイトに対して繰り返します。

//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114

"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}

@see String#bytes...

String#each_codepoint -> Enumerator (15121.0)

文字列の各コードポイントに対して繰り返します。

...ます。

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}

@see String#codepoints...

String#each_codepoint {|codepoint| block } -> self (15121.0)

文字列の各コードポイントに対して繰り返します。

...ます。

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}

@see String#codepoints...

String#each_char -> Enumerator (15115.0)

文字列の各文字に対して繰り返します。

...文字列の各文字に対して繰り返します。

たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界

@see String#chars...
<< 1 2 3 ... > >>