るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. t61string new
  4. matrix t
  5. fiddle type_size_t

ライブラリ

キーワード

検索結果

<< < ... 3 4 5 6 7 ... > >>

String#bytesize -> Integer (15214.0)

文字列のバイト長を整数で返します。

...文字列のバイト長を整数で返します。

//emlist[例][ruby]{
#coding:UTF-8
# 実行結果は文字コードによって異なります。
p "いろは".size #=> 3
p "いろは".bytesize #=> 9
//}

@see String#size...

String#each_byte {|byte| ... } -> self (15214.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#split(sep = $;, limit = 0) {|s| ... } -> self (15205.0)

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

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

第 1 引数 sep は以下...
...が配列に含まれます。

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

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

@param sep...
...param limit 分割する最大個数

@return ブロックを渡した場合は self、ブロックなしの場合は配列

//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]

p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ') #...

String#start_with?(*prefixes) -> bool (15156.0)

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

... true を返します。

@param prefixes パターンを表す文字列または正規表現 (のリスト)

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

@see String#end_with?
@see String#delete_prefix, String#delete_prefix!...

String#to_f -> Float (15150.0)

文字列を 10 進数表現と解釈して、浮動小数点数 Float に変換します。

...数 Float に変換します。

浮動小数点数とみなせなくなるところまでを変換対象とします。
途中に変換できないような文字列がある場合、それより先の文字列は無視されます。

//emlist[][ruby]{
p "-10".to_f # => -10.0
p "10e2".to_f # =>...
...1000.0
p "1e-2".to_f # => 0.01
p ".1".to_f # => 0.1

p "1_0_0".to_f # => 100.0 # 数値リテラルと同じように区切りに _ を使える
p " \n10".to_f # => 10.0 # 先頭の空白・改行は無視される
p "7xa.5".to_f # => 7.0
//}

以下の例は、先頭に浮動小数点数と...
...列のケースでも、0.0 を返します。

//emlist[][ruby]{
p "".to_f # => 0.0
p "nan".to_f # => 0.0
p "INF".to_f # => 0.0
p "-Inf".to_f # => 0.0
//}

変換後の Float が有限の値を取れないときは、Float::INFINITY を用います。
このとき、全ての警告を有...

絞り込み条件を変える

String#to_i(base = 10) -> Integer (15150.0)

文字列を 10 進数表現された整数であると解釈して、整数に変換します。

...ist[例][ruby]{
p " 10".to_i # => 10
p "+10".to_i # => 10
p "-10".to_i # => -10

p "010".to_i # => 10
p "-010".to_i # => -10
//}

整数とみなせない文字があればそこまでを変換対象とします。
変換対象が空文字列であれば 0 を返します。

//emlist[...
...例][ruby]{
p "0x11".to_i # => 0
p "".to_i # => 0
//}

基数を指定することでデフォルトの 10 進以外に 2 〜 36 進数表現へ変換できます。
それぞれ Ruby の整数リテラルで使用可能なプリフィクスは無視されます。
また、base に 0 を指...
...gumentError が発生します。

//emlist[例][ruby]{
p "01".to_i(2) # => 1
p "0b1".to_i(2) # => 1

p "07".to_i(8) # => 7
p "0o7".to_i(8) # => 7

p "1f".to_i(16) # => 31
p "0x1f".to_i(16) # => 31

p "0b10".to_i(0) # => 2
p "0o10".to_i(0) # => 8
p "010".to_i(0) # => 8
p "0d10".to_i(...

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

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

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

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

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

@see String#sta...
...rt_with?
@see String#delete_suffix, String#delete_suffix!...

String#oct -> Integer (15144.0)

文字列を 8 進文字列であると解釈して、整数に変換します。

...//emlist[例][ruby]{
p "10".oct # => 8
p "010".oct # => 8
p "8".oct # => 0
//}

oct は文字列の接頭辞 ("0", "0b", "0B", "0x", "0X") に応じて
8 進以外の変換も行います。

//emlist[例][ruby]{
p "0b10".oct # => 2
p "10".oct # => 8
p "010".oct # => 8
p "0x10".oct # => 1...
...//emlist[例][ruby]{
p "-010".oct # => -8
p "-0x10".oct # => -16
p "-0b10".oct # => -2

p "1_0_1x".oct # => 65
//}

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

逆に、数値を文字列に変換するにはKernel.#sprintf,
String
#%, Integer#to_s を...

String#capitalize!(*options) -> self | nil (15138.0)

文字列先頭の文字を大文字に、残りを小文字に破壊的に変更します。

...options オプションの詳細は String#downcase を参照してください。

@return capitalize! は self を変更して返しますが、
変更が起こらなかった場合は 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#delete_suffix!(suffix) -> self | nil (15138.0)

self の末尾から破壊的に suffix を削除します。

...ます。

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

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

@see String#chomp!
@see String#chop!
@see String#delete_prefix!
@see String#delete_suffix
@see String#end_with?...

絞り込み条件を変える

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

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

...@return capitalize! は self を変更して返しますが、
変更が起こらなかった場合は nil を返します。

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

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

@see String#capitalize, String#u...
...pcase!,
String
#downcase!, String#swapcase!...

String#codepoints -> [Integer] (15132.0)

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

...odepoint.to_a と同じです)

//emlist[例][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...
<< < ... 3 4 5 6 7 ... > >>