るりまサーチ

最速Rubyリファレンスマニュアル検索!
1016件ヒット [501-600件を表示] (0.041秒)
トップページ > クラス:String[x] > クエリ:b[x]

別のキーワード

  1. string b
  2. _builtin b
  3. b string
  4. b _builtin

ライブラリ

キーワード

検索結果

<< < ... 4 5 6 7 8 ... > >>

String#each_char {|cstr| block } -> self (101.0)

文字列の各文字に対して繰り返します。

...文字列の各文字に対して繰り返します。

たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界

@see String#chars...

String#each_codepoint {|codepoint| block } -> self (101.0)

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

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

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

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 1...
...08, 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_grapheme_cluster {|grapheme_cluster| block } -> self (101.0)

文字列の書記素クラスタに対して繰り返します。

...

String
#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#g...

String#empty? -> bool (101.0)

文字列が空 (つまり長さ 0) の時、真を返します。

...文字列が空 (つまり長さ 0) の時、真を返します。

//emlist[例][ruby]{
"hello".empty? #=> false
" ".empty? #=> false
"".empty? #=> true
//}...

String#end_with?(*strs) -> bool (101.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?...
...@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#eql?(other) -> bool (101.0)

文字列の内容が文字列 other の内容と等しいときに true を返します。 等しくなければ false を返します。

...りません。
つまり、"string".eql?(str) という式を実行した場合には、
str が "string" という内容の文字列でありさえすれば常に true を返します。
同一のオブジェクトであるかどうかを判定したいときは
Object#equal? を使ってくださ...
...String#upcase,
String
#downcase で大文字小文字を揃えてから比較してください。

Hash クラス内での比較に使われます。

@param other 任意のオブジェクト
@return true か false

//emlist[例][ruby]{
p "string".eql?("string") # => true
p "string".e...
...ql?("STRING") # => false
p "string".eql?("") # => false
p "".eql?("string") # => false

p "string".eql?("str" + "ing") # => true (内容が同じなら true)
p "string".eql?("stringX".chop) # => true (内容が同じなら true)

p "string".upcase.eql?("String".upcase) # =>...
...場合は
String
#casecmp? を使ってください。

Hash クラス内での比較に使われます。

@param other 任意のオブジェクト
@return true か false

//emlist[例][ruby]{
p "string".eql?("string") # => true
p "string".eql?("STRING") # => false
p "string".eql?("")...
...# => false
p "".eql?("string") # => false

p "string".eql?("str" + "ing") # => true (内容が同じなら true)
p "string".eql?("stringX".chop) # => true (内容が同じなら true)
//}

@see Hash, String#<=>, String#casecmp, String#==...

String#grapheme_clusters {|grapheme_cluster| block } -> self (101.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_graphem...

String#include?(substr) -> bool (101.0)

文字列中に部分文字列 substr が含まれていれば真を返します。

...文字列中に部分文字列 substr が含まれていれば真を返します。

@param substr 検索する文字列

//emlist[例][ruby]{
"hello".include? "lo" #=> true
"hello".include? "ol" #=> false
"hello".include? ?h #=> true
//}...

String#intern -> Symbol (101.0)

文字列に対応するシンボル値 Symbol を返します。

...値 Symbol を返します。

なお、このメソッドの逆にシンボルに対応する文字列を得るには
Symbol#to_s または Symbol#id2name を使います。

シンボル文字列にはヌルキャラクタ("\0")、空の文字列の使用も可能です。

//emlist[例][ruby]{
p...

String#iseuc -> bool (101.0)

self が 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\xc0\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 # => false
//}...

絞り込み条件を変える

String#isjis -> bool (101.0)

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

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

Kconv.isjis(self) と同じです。
<< < ... 4 5 6 7 8 ... > >>