るりまサーチ

最速Rubyリファレンスマニュアル検索!
1016件ヒット [701-800件を表示] (0.112秒)

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method gets
  4. irb/input-method new
  5. matrix -

ライブラリ

キーワード

検索結果

<< < ... 6 7 8 9 10 ... > >>

String#succ -> String (9252.0)

self の「次の」文字列を返します。

...アルファベット順(aの次はb, zの次はa, 大文字も同様)に、
数字なら 10 進数(9 の次は 0)とみなして計算されます。

//emlist[][ruby]{
p "aa".succ # => "ab"
p "88".succ.succ # => "90"
//}

"99" → "100", "AZZ" → "BAA" のような繰り上げも行わ...
...れます。
このとき負符号などは考慮されません。

//emlist[][ruby]{
p "99".succ # => "100"
p "ZZ".succ # => "AAA"
p "a9".succ # => "b0"
p "-9".succ # => "-10"
//}

self にアルファベットや数字とそれ以外の文字が混在している場合、
アルファベ...
...なり、残りは保存されます。

//emlist[][ruby]{
p "1.9.9".succ # => # "2.0.0"
//}

逆に self がアルファベットや数字をまったく含まない場合は、
単純に文字コードを 1 増やします。

//emlist[][ruby]{
p ".".succ # => "/"
//}

さらに、self が空...

String#each_codepoint {|codepoint| block } -> self (9244.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 (9244.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#codepoints {|codepoint| block } -> self (9238.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#+(other) -> String (9233.0)

文字列と other を連結した新しい文字列を返します。

...er を連結した新しい文字列を返します。

@param other 文字列
@return self と other を連結した文字列

//emlist[例][ruby]{
p "str" + "ing" # => "string"

a = "abc"
b
= "def"
p a + b # => "abcdef"
p a # => "abc" (変化なし)
p b # => "def"
//}...

絞り込み条件を変える

String#chars {|cstr| block } -> self (9233.0)

文字列の各文字を文字列の配列で返します。(self.each_char.to_a と同じです)

...t[例][ruby]{
"hello世界".chars # => ["h", "e", "l", "l", "o", "世", "界"]
//}

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

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

@see String#each_...

String#grapheme_clusters {|grapheme_cluster| block } -> self (9233.0)

文字列の書記素クラスタの配列を返します。(self.each_grapheme_cluster.to_a と同じです)

.../emlist[例][ruby]{
"a\u0300".grapheme_clusters # => ["à"]
//}

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

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

@see String#each_graphe...

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

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

...します。

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

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

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

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

@see String#casecmp...

String#end_with?(*strs) -> bool (9232.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#start_with?(*strs) -> bool (9232.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#unicode_normalized?(form = :nfc) -> bool (9232.0)

self が引数 form で指定された正規化形式で Unicode 正規化された文字列か どうかを返します。

...す。省略した場合は :nfc になります。

@raise Encoding::CompatibilityError self が Unicode 文字列ではない場合
に発生します。

//emlist[例][ruby]{
"a\u0300".unicode_normalized? # => false
"a\u0300".unicode_normalized?(:n...
...=> true
"\u00E0".unicode_normalized? # => true
"\u00E0".unicode_normalized?(:nfd) # => false
"\xE0".force_encoding('ISO-8859-1').unicode_normalized?
# => Encoding::CompatibilityError raised
//}

@see String#unicode_normalize, String#unicode_normalize!...

String#iseuc -> bool (9230.0)

self が EUC-JP なバイト列として正当であるかどうかを判定します。

...EUC-JP なバイト列として正当であるかどうかを判定します。

Kconv.#iseuc(self) と同じです。

//emlist[例][ruby]{
require 'kconv'

euc_str = "\
\xa5\xaa\xa5\xd6\xa5\xb8\xa5\xa7\xa5\xaf\xa5\xc8\xbb\xd8\xb8\xfe\
\xa5\xd7\xa5\xed\xa5\xb0\xa5\xe9\xa5\xdf\xa5\xf3\xa5\xb0\xb8\x...
...c0\xb8\xec\
\x52\x75\x62\x79".force_encoding('EUC-JP')

sjis_str = "\
\x83\x49\x83\x75\x83\x57\x83\x46\x83\x4e\x83\x67\x8e\x77\x8c\xfc\
\x83\x76\x83\x8d\x83\x4f\x83\x89\x83\x7e\x83\x93\x83\x4f\x8c\xbe\x8c\xea\
\x52\x75\x62\x79".force_encoding('Shift_JIS')

euc_str.iseuc # => true
sjis_str.iseuc # =...
<< < ... 6 7 8 9 10 ... > >>