るりまサーチ

最速Rubyリファレンスマニュアル検索!
2130件ヒット [601-700件を表示] (0.122秒)
トップページ > クエリ:ruby[x] > クエリ:Ruby[x] > クエリ:string[x] > クエリ:String[x] > クラス:String[x] > 種類:インスタンスメソッド[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

<< < ... 5 6 7 8 9 ... > >>

String#+@ -> String | self (30240.0)

self が freeze されている文字列の場合、元の文字列の複製を返します。 freeze されていない場合は self を返します。

...文字列の場合、元の文字列の複製を返します。
freeze されていない場合は self を返します。

//emlist[例][ruby]{
# frozen_string_literal: false

original_text = "text"
unfrozen_text = +original_text
unfrozen_text.frozen? # => false
original_text == unf...
..._text # => true
original_text.equal?(unfrozen_text) # => true

original_text = "text".freeze
unfrozen_text = +original_text
unfrozen_text.frozen? # => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_text) # => false
//}

@see String#-@...

String#-@ -> String | self (30240.0)

self が freeze されている文字列の場合、self を返します。 freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。

...freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。

//emlist[例][ruby]{
# frozen_string_literal: false

original_text = "text"
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_t...
...ext # => true
original_text.equal?(frozen_text) # => false

original_text = "text".freeze
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => true
//}

@see String#+@...

String#byteslice(nth) -> String | nil (30240.0)

nth バイト目の文字を返します。nth が負の場合は文字列の末尾から数えます。 引数が範囲外を指定した場合は nil を返します。

...rn 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。

//emlist[例][ruby]{
"hello".byteslice(1) # => "e"
"hello".byteslice(-1) # => "o"
"\u3042".byteslice(0) # => "\xE3"
"\u3042".byteslice(1) # => "\x81"
//}

@see String#slice...

String#byteslice(nth, len=1) -> String | nil (30240.0)

nth バイト目から長さ len バイトの部分文字列を新しく作って返します。 nth が負の場合は文字列の末尾から数えます。引数が範囲外を指定した場合は nil を返します。

...数で指定します。

@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。

//emlist[例][ruby]{
"hello".byteslice(1, 2) # => "el"
"\u3042\u3044\u3046".byteslice(0, 3) # => "\u3042"
//}

@see String#slice...

String#byteslice(range) -> String | nil (30240.0)

range で指定したバイトの範囲に含まれる部分文字列を返します。引数が範囲 外を指定した場合は nil を返します。

...を示す Range オブジェクト

@return 切り出した文字列を返します。戻り値の文字エンコーディングは自身
と同じです。

//emlist[例][ruby]{
"hello".byteslice(1..2) # => "el"
"\x03\u3042\xff".byteslice(1..3) # => "\u3042"
//}

@see String#slice...

絞り込み条件を変える

String#center(width, padding = &#39; &#39;) -> String (30240.0)

長さ width の文字列に self を中央寄せした文字列を返します。 self の長さが width より長い時には元の文字列の複製を返します。 また、第 2 引数 padding を指定したときは 空白文字の代わりに padding を詰めます。

...idth 返り値の文字列の最小の長さ
@param padding 長さが width になるまで self の両側に詰める文字

//emlist[例][ruby]{
p "foo".center(10) # => " foo "
p "foo".center(9) # => " foo "
p "foo".center(8) # => " foo "
p "foo".center(7)...
...# => " foo "
p "foo".center(3) # => "foo"
p "foo".center(2) # => "foo"
p "foo".center(1) # => "foo"
p "foo".center(10, "*") # => "***foo****"
//}

@see String#ljust, String#rjust...

String#ljust(width, padding = &#39; &#39;) -> String (30240.0)

長さ width の文字列に self を左詰めした文字列を返します。 self の長さが width より長い時には元の文字列の複製を返します。 また、第 2 引数 padding を指定したときは 空白文字の代わりに padding を詰めます。

.../emlist[例][ruby]{
p "foo".ljust(10) # => "foo "
p "foo".ljust(9) # => "foo "
p "foo".ljust(8) # => "foo "
p "foo".ljust(2) # => "foo"
p "foo".ljust(1) # => "foo"
p "foo".ljust(10, "*") # => "foo*******"
//}

@see String#center, String#rjust...

String#lstrip -> String (30240.0)

文字列の先頭にある空白文字を全て取り除いた新しい文字列を返します。 空白文字の定義は " \t\r\n\f\v\0" です。

...にある空白文字を全て取り除いた新しい文字列を返します。
空白文字の定義は " \t\r\n\f\v\0" です。

//emlist[例][ruby]{
p " abc\n".lstrip #=> "abc\n"
p "\t abc\n".lstrip #=> "abc\n"
p "abc\n".lstrip #=> "abc\n"
//}

@see String#strip, String#rstrip...

String#rjust(width, padding = &#39; &#39;) -> String (30240.0)

長さ width の文字列に self を右詰めした文字列を返します。 self の長さが width より長い時には元の文字列の複製を返します。 また、第 2 引数 padding を指定したときは 空白文字の代わりに padding を詰めます。

.../emlist[例][ruby]{
p "foo".rjust(10) # => " foo"
p "foo".rjust(9) # => " foo"
p "foo".rjust(8) # => " foo"
p "foo".rjust(2) # => "foo"
p "foo".rjust(1) # => "foo"
p "foo".rjust(10, "*") # => "*******foo"
//}

@see String#center, String#ljust...

String#rstrip -> String (30240.0)

文字列の末尾にある空白文字を全て取り除いた新しい文字列を返します。 空白文字の定義は " \t\r\n\f\v\0" です。

...[例][ruby]{
p " abc\n".rstrip #=> " abc"
p " abc \t\r\n\0".rstrip #=> " abc"
p " abc".rstrip #=> " abc"
p " abc\0 ".rstrip #=> " abc"

str = "abc\n"
p str.rstrip #=> "abc"
p str #=> "abc\n" (元の文字列は変化しない)
//}

@see String#lstr...

絞り込み条件を変える

String#strip -> String (30240.0)

文字列先頭と末尾の空白文字を全て取り除いた文字列を生成して返します。 空白文字の定義は " \t\r\n\f\v\0" です。

...尾の空白文字を全て取り除いた文字列を生成して返します。
空白文字の定義は " \t\r\n\f\v\0" です。

//emlist[例][ruby]{
p " abc \r\n".strip #=> "abc"
p "abc\n".strip #=> "abc"
p " abc".strip #=> "abc"
p "abc".strip #=> "abc"
p "...
...\0 abc \0".strip #=> "abc"

str = "\tabc\n"
p str.strip #=> "abc"
p str #=> "\tabc\n" (元の文字列は変化しない)
//}

@see String#lstrip, String#rstrip...
<< < ... 5 6 7 8 9 ... > >>