るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

String#==(other) -> bool (39177.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false...
...st[例][ruby]{
string
like = Object.new

def stringlike.==(other)
"string" == other
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str
raise
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}

@see String#eql?...

String#===(other) -> bool (30277.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false...
...st[例][ruby]{
string
like = Object.new

def stringlike.==(other)
"string" == other
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str
raise
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}

@see String#eql?...

String#downcase(*options) -> String (21156.0)

全ての大文字を対応する小文字に置き換えた文字列を返します。 どの文字がどう置き換えられるかは、オプションの有無や文字列のエンコーディングに依存します。

...数でも)。ラウンドトリップできるという仮定も
成り立ちません (例えば str.downcase == str.upcase.downcase)。
そして、Unicode 正規化 (すなわち String#unicode_normalize) はケース
マッピング操作で必ずしも維持されるとは限りません。...
...16BE/LE,
UTF-32BE/LE, ISO-8859-1~16 の String/Symbol でサポートされています。
他のエンコーディングもサポートされる予定です。


//emlist[例][ruby]{
p "STRing?".downcase # => "string?"
//}
@see String#downcase!, String#upcase, String#swapcase, String#capitalize...

String#-@ -> String | self (21127.0)

self が freeze されている文字列の場合、self を返します。 freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。

...できる限り既存の) 複製を返します。

//emlist[例][ruby]{
# frozen_string_literal: false

original_text = "text"
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => false

ori...
...ginal_text = "text".freeze
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => true
//}

@see String#+@...

String#dedup -> String | self (21127.0)

self が freeze されている文字列の場合、self を返します。 freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。

...できる限り既存の) 複製を返します。

//emlist[例][ruby]{
# frozen_string_literal: false

original_text = "text"
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => false

ori...
...ginal_text = "text".freeze
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => true
//}

@see String#+@...

絞り込み条件を変える

String#+@ -> String | self (21126.0)

self が freeze されている文字列の場合、元の文字列の複製を返します。 freeze されていない場合は self を返します。

...ていない場合は self を返します。

//emlist[例][ruby]{
# frozen_string_literal: false

original_text = "text"
unfrozen_text = +original_text
unfrozen_text.frozen? # => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_text) # => true...
...original_text = "text".freeze
unfrozen_text = +original_text
unfrozen_text.frozen? # => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_text) # => false
//}

@see String#-@...

String#-@ -> String | self (21126.0)

self が freeze されている文字列の場合、self を返します。 freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。

...できる限り既存の) 複製を返します。

//emlist[例][ruby]{
# frozen_string_literal: false

original_text = "text"
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => false

ori...
...ginal_text = "text".freeze
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => true
//}

@see String#+@...

String#split(sep = $;, limit = 0) -> [String] (21126.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...列に含まれます。

第 2 引数 limit は以下のいずれかです。

: limit > 0
最大 limit 個の文字列に分割する
: limit == 0
分割個数制限はなしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし

@param sep...
...//emlist[文字列全体を 1 文字ずつに分割する例][ruby]{
p 'hi there'.split(//).join(':') # => "h:i: :t:h:e:r:e"
//}

//emlist[limit == 0 だと制限なく分割、配列末尾の空文字列は取り除かれる][ruby]{
p "a,b,c,,,".split(/,/, 0) # => ["a", "b", "c"]
//}

//emli...
..."a,b,c,d,e".split(/,/, 6) # => ["a", "b", "c", "d", "e"]
p "a,b,c,d,e".split(/,/, 7) # => ["a", "b", "c", "d", "e"]
//}

//emlist[limit が負の数の場合は制限なく分割][ruby]{
p "a,b,c,,,".split(/,/, -1) # => ["a", "b", "c", "", "", ""]
//}

@see String#partition, String#rpartition...

String#[](nth) -> String | nil (21125.0)

nth 番目の文字を返します。 nth が負の場合は文字列の末尾から数えます。 つまり、 self.size + nth 番目の文字を返します。

...を返します。

@param nth 文字の位置を表す整数
@return 指定した位置の文字を表す String オブジェクト

//emlist[例][ruby]{
p 'bar'[2] # => "r"
p 'bar'[2] == ?r # => true
p 'bar'[-1] # => "r"
p 'bar'[3] # => nil
p 'bar'[-4] # => nil
//}

このメ...

String#slice(nth) -> String | nil (21125.0)

nth 番目の文字を返します。 nth が負の場合は文字列の末尾から数えます。 つまり、 self.size + nth 番目の文字を返します。

...を返します。

@param nth 文字の位置を表す整数
@return 指定した位置の文字を表す String オブジェクト

//emlist[例][ruby]{
p 'bar'[2] # => "r"
p 'bar'[2] == ?r # => true
p 'bar'[-1] # => "r"
p 'bar'[3] # => nil
p 'bar'[-4] # => nil
//}

このメ...

絞り込み条件を変える

String#dump -> String (21124.0)

文字列中の非表示文字をバックスラッシュ記法に置き換えた文字列を返します。 str == eval(str.dump) となることが保証されています。

...文字列中の非表示文字をバックスラッシュ記法に置き換えた文字列を返します。
str == eval(str.dump) となることが保証されています。

//emlist[例][ruby]{
# p だとさらにバックスラッシュが増えて見にくいので puts している
puts "ab...
...字列を返します。
str == eval(str.dump) となることが保証されています。

//emlist[例][ruby]{
# p だとさらにバックスラッシュが増えて見にくいので puts している
puts "abc\r\n\f\x00\b10\\\"".dump # => "abc\r\n\f\000\01010\\\""
//}

@see String#undump...

String#[](nth, len) -> String | nil (21115.0)

nth 文字目から長さ len 文字の部分文字列を新しく作って返します。 nth が負の場合は文字列の末尾から数えます。

nth 文字目から長さ len 文字の部分文字列を新しく作って返します。
nth が負の場合は文字列の末尾から数えます。

@param nth 取得したい文字列の開始インデックスを整数で指定します。
@param len 取得したい文字列の長さを正の整数で指定します。

@return nth が範囲外を指す場合は nil を返します。

//emlist[例][ruby]{
str0 = "bar"
str0[2, 1] #=> "r"
str0[2, 0] #=> ""
str0[2, 100] #=> "r" (右側を超えても...
<< 1 2 3 ... > >>