るりまサーチ

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

別のキーワード

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

ライブラリ

モジュール

オブジェクト

検索結果

<< 1 2 3 ... > >>

StringIO#each(rs = $/) -> Enumerator (21116.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 (21116.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...

Readline::HISTORY.each {|string| ... } (18221.0)

ヒストリの内容に対してブロックを評価します。 ブロックパラメータにはヒストリの最初から最後までの内容を順番に渡します。

...sh("foo", "bar", "baz")
Readline::HISTORY.each do |s|
p s #=> "foo", "bar", "baz"
end

例: Enumerator オブジェクトを返す場合。

require "readline"

Readline::HISTORY.push("foo", "bar", "baz")
e = Readline::HISTORY.each
e.each do |s|
p s #=> "foo", "bar", "baz"
en...

Readline::HISTORY.each -> Enumerator (18121.0)

ヒストリの内容に対してブロックを評価します。 ブロックパラメータにはヒストリの最初から最後までの内容を順番に渡します。

...sh("foo", "bar", "baz")
Readline::HISTORY.each do |s|
p s #=> "foo", "bar", "baz"
end

例: Enumerator オブジェクトを返す場合。

require "readline"

Readline::HISTORY.push("foo", "bar", "baz")
e = Readline::HISTORY.each
e.each do |s|
p s #=> "foo", "bar", "baz"
en...

String#each_grapheme_cluster -> Enumerator (15132.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 (15132.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 (15120.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 (15120.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 (15120.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...
<< 1 2 3 ... > >>