るりまサーチ

最速Rubyリファレンスマニュアル検索!
2130件ヒット [1301-1400件を表示] (0.092秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< < ... 12 13 14 15 16 ... > >>

String#capitalize! -> self | nil (30062.0)

文字列先頭の文字を大文字に、残りを小文字に変更します。 ただし、アルファベット以外の文字は位置に関わらず変更しません。

...ますが、
変更が起こらなかった場合は nil を返します。

//emlist[例][ruby]{
str = "foobar"
str.capitalize!
p str # => "Foobar"

str = "fooBAR"
str.capitalize!
p str # => "Foobar"
//}

@see String#capitalize, String#upcase!,
String
#downcase!, String#swapcase!...

String#codepoints -> [Integer] (30062.0)

文字列の各コードポイントの配列を返します。(self.each_codepoint.to_a と同じです)

...ist[例][ruby]{
#coding:UTF-8
"hello わーるど".codepoints
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
//}

ブロックが指定された場合は String#each_codepoint と同じように動作します。

Ruby
2.6 までは deprecated の警告が出ますが、Ruby 2.7 で...
...警告は削除されました。

@see String#each_codepoint...

String#codepoints {|codepoint| block } -> self (30062.0)

文字列の各コードポイントの配列を返します。(self.each_codepoint.to_a と同じです)

...ist[例][ruby]{
#coding:UTF-8
"hello わーるど".codepoints
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
//}

ブロックが指定された場合は String#each_codepoint と同じように動作します。

Ruby
2.6 までは deprecated の警告が出ますが、Ruby 2.7 で...
...警告は削除されました。

@see String#each_codepoint...

String#end_with?(*strs) -> bool (30062.0)

self の末尾が strs のいずれかであるとき true を返します。

...ずれかであるとき true を返します。

@param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}

@see String#start_with?...

String#hex -> Integer (30062.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...0 を返します。

//emlist[例][ruby]{
p "10".hex # => 16
p "ff".hex # => 255
p "0x10".hex # => 16
p "-0x10".hex # => -16

p "xyz".hex # => 0
p "10z".hex # => 16
p "1_0".hex # => 16

p "".hex # => 0
//}

@see String#oct, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#...
...Float

このメソッドの逆に数値を文字列に変換するには
Kernel.#sprintf, String#%,
Integer#to_s
などを使ってください。...

絞り込み条件を変える

String#start_with?(*strs) -> bool (30062.0)

self の先頭が strs のいずれかであるとき true を返します。

...れかであるとき true を返します。

@param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".start_with?("str") # => true
"string".start_with?("ing") # => false
"string".start_with?("ing", "str") # => true
//}

@see String#end_with?...

String#swapcase! -> self | nil (30062.0)

'A' から 'Z' までのアルファベット大文字を小文字に、 'a' から 'z' までのアルファベット小文字を大文字に、破壊的に変更します。

...すが、
置換が起こらなかった場合は nil を返します。

このメソッドはマルチバイト文字を認識しません。

//emlist[例][ruby]{
str = "ABCxyz"
str.swapcase!
p str # => "abcXYZ"
//}

@see String#swapcase, String#upcase!, String#downcase!, String#capitalize!...

String#gsub(pattern) -> Enumerator (30058.0)

文字列中で pattern にマッチした部分を順番にブロックに渡し、 その実行結果で置き換えた文字列を生成して返します。 ブロックなしの場合と違い、ブロックの中からは 組み込み変数 $1, $2, $3, ... を問題なく参照できます。

...表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@return 新しい文字列

//emlist[例][ruby]{
p 'abcabc'.gsub(/[bc]/) {|s| s.upcase } #=> "aBCaBC"
p 'abcabc'.gsub(/[bc]/) { $&.upcase } #=> "aBCaBC"
//}

@see String#sub, String#scan...

String#[]=(nth, len, val) (30056.0)

nth 番目の文字から len 文字の部分文字列を文字列 val で置き換えます。

...@param len 置き換えたい部分文字列の長さ
@param val 指定範囲の部分文字列と置き換える文字列

@return val を返します。

//emlist[例][ruby]{
buf = "string"
buf[1, 4] = "!!"
p buf # => "s!!g"

buf = "string"
buf[1, 0] = "!!"
p buf # => "s!!tring"
//}...

String#[]=(substr, val) (30056.0)

文字列中の substr に一致する最初の部分文字列を文字列 val で置き換えます。

...列と置き換える文字列

@return val を返します。

@raise IndexError self が部分文字列 substr を含まない場合に発生します。

//emlist[例][ruby]{
buf = "string"
buf["trin"] = "!!"
p buf # => "s!!g"

buf = "string"
buf["nosuchstring"] = "!!" # IndexError
//}...

絞り込み条件を変える

String#delete_prefix!(prefix) -> self | nil (30050.0)

self の先頭から破壊的に prefix を削除します。

...ら削除する文字列を指定します。

@return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_prefix!("hel") # => "lo"
"hello".delete_prefix!("llo") # => nil
//}

@see String#delete_prefix
@see String#delete_suffix!
@see String#start_with?...

String#match?(regexp, pos = 0) -> bool (30050.0)

regexp.match?(self, pos) と同じです。 regexp が文字列の場合は、正規表現にコンパイルします。 詳しくは Regexp#match? を参照してください。

...正規表現にコンパイルします。
詳しくは Regexp#match? を参照してください。

//emlist[例][ruby]{
"Ruby".match?(/R.../) #=> true
"Ruby".match?(/R.../, 1) #=> false
"Ruby".match?(/P.../) #=> false
$& #=> nil
//}

@see Regexp#match?, Symbol#match?...
<< < ... 12 13 14 15 16 ... > >>