るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

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

String#bytes -> [Integer] (9150.0)

文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)

...と同じです)

//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}

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

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

@see String#each_byte...

String#bytes {|byte| ... } -> self (9150.0)

文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)

...と同じです)

//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}

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

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

@see String#each_byte...

String#chomp!(rs = $/) -> self | nil (9150.0)

self の末尾から rs で指定する改行コードを取り除きます。 ただし rs が "\n" ($/ のデフォルト値) のときは、 実行環境によらず "\r", "\r\n", "\n" のすべてを改行コードとみなして取り除きます。

...ます。

//emlist[例][ruby]{
buf = "string\n"
buf.chomp! # => nil
p buf # => "string"

$/ = "\n" # デフォルトと同じ
p "foo\r".chomp! # => "foo"
p "foo\r\n".chomp! # => "foo"
p "foo\n".chomp! # => "foo"
p "foo\n\r".chomp! # => "foo\n"

buf = "string\n"
buf.chomp!(nil) # =...
...> nil
p buf # => "string\n"

p "foo\r\n\n".chomp!("") # => "foo"
p "foo\n\r\n".chomp!("") # => "foo"
p "foo\n\r\r".chomp!("") # => nil
//}

@see String#chomp
@see String#chop!...

String#chop! -> self | nil (9150.0)

文字列の最後の文字を取り除きます。 ただし、終端が "\r\n" であればその 2 文字を取り除きます。

...った場合は nil を返します。

//emlist[例][ruby]{
str = "string\r\n"
ret = str.chop!
ret # => "string"
str # => "string"
str.chop! # => "strin"
"".chop! # => nil
//}

@see String#chomp!
@see String#chop
@see String#delete_suffix!...

String#downcase! -> self | nil (9150.0)

文字列中の 'A' から 'Z' までの アルファベット大文字をすべて破壊的に小文字に置き換えます。 アルファベット大文字以外の文字はすべてそのまま保存されます。

...文字小文字までは変換しません。
@return self を変更して返します。変更が無かった場合は nil を返します。

//emlist[例][ruby]{
str = "STRing?"
str.downcase!
p str # => "string?"
//}

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

絞り込み条件を変える

String#each_codepoint -> Enumerator (9150.0)

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

...各コードポイントに対して繰り返します。

UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE) 以外のエンコーディングに対しては
各文字のバイナリ表現由来の値になります。

//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 (9150.0)

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

...各コードポイントに対して繰り返します。

UTF-8/UTF-16(BE|LE)/UTF-32(BE|LE) 以外のエンコーディングに対しては
各文字のバイナリ表現由来の値になります。

//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#end_with?(*strs) -> bool (9150.0)

self の末尾が strs のいずれかであるとき 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?
@see String#delete_suffix, String#delete_suffix!...

String#match?(regexp, pos = 0) -> bool (9150.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?...

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

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

...

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

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

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

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

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

絞り込み条件を変える

String#casecmp?(other) -> bool | nil (9144.0)

大文字小文字の違いを無視し文字列を比較します。 文字列が一致する場合には true を返し、一致しない場合には false を返します。

...る場合には true を返し、一致しない場合には false を返します。

@param other self と比較する文字列

//emlist[例][ruby]{
"abcdef".casecmp?("abcde") #=> false
"aBcDeF".casecmp?("abcdef") #=> true
"abcdef".casecmp?("abcdefg") #=> false
"abcdef".casecmp?("ABCD...
...EF") #=> true
"\u{e4 f6 fc}".casecmp?("\u{c4 d6 dc}") #=> true
//}

nil は文字列のエンコーディングが非互換の時に返されます。

//emlist[][ruby]{
"\u{e4 f6 fc}".encode("ISO-8859-1").casecmp?("\u{c4 d6 dc}") #=> nil
//}

@see String#casecmp...

String#chop! -> self | nil (9144.0)

文字列の最後の文字を取り除きます。 ただし、終端が "\r\n" であればその 2 文字を取り除きます。

...取り除く文字がなかった場合は nil を返します。

//emlist[例][ruby]{
str = "string\r\n"
ret = str.chop!
ret # => "string"
str # => "string"
str.chop! # => "strin"
"".chop! # => nil
//}

@see String#chomp!
@see String#chop...
<< < ... 12 13 14 15 16 ... > >>