るりまサーチ

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

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub

ライブラリ

クラス

キーワード

検索結果

String#rpartition(sep) -> [String, String, String] (39428.0)

セパレータ sep が最後に登場する部分で self を 3 つに分割し、 [最後のセパレータより前の部分, セパレータ, それ以降の部分] の 3 要素の配列を返します。

...と第 2 要素が空文字列になります。

@param sep セパレータを表す文字列か正規表現を指定します。

//emlist[例][ruby]{
p "axaxa".rpartition("x") # => ["axa", "x", "a"]
p "aaaaa".rpartition("x") # => ["", "", "aaaaa"]
//}

@see String#partition, String#split...

String#partition(sep) -> [String, String, String] (21321.0)

セパレータ sep が最初に登場する部分で self を 3 つに分割し、 [最初のセパレータより前の部分, セパレータ, それ以降の部分] の 3 要素の配列を返します。

...@param sep セパレータを表す文字列か正規表現を指定します。

//emlist[例][ruby]{
p "axaxa".partition("x") # => ["a", "x", "axa"]
p "aaaaa".partition("x") # => ["aaaaa", "", ""]
p "aaaaa".partition("") # => ["", "", "aaaaa"]
//}

@see String#rpartition, String#split...

String#split(sep = $;, limit = 0) -> [String] (21119.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。

..."a,b,c,d,e".split(/,/, 6) # => ["a", "b", "c", "d", "e"]
p "a,b,c,d,e".split(/,/, 7) # => ["a", "b", "c", "d", "e"]
//}

//emlist[limit が負の数の場合は制限なく分割][ruby]{
p "a,b,c,,,".split(/,/, -1) # => ["a", "b", "c", "", "", ""]
//}

@see String#partition, String#rpartition...

String#split(sep = $;, limit = 0) {|s| ... } -> self (21019.0)

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

..."a,b,c,d,e".split(/,/, 6) # => ["a", "b", "c", "d", "e"]
p "a,b,c,d,e".split(/,/, 7) # => ["a", "b", "c", "d", "e"]
//}

//emlist[limit が負の数の場合は制限なく分割][ruby]{
p "a,b,c,,,".split(/,/, -1) # => ["a", "b", "c", "", "", ""]
//}

@see String#partition, String#rpartition...

NEWS for Ruby 3.0.0 (264.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...", "f", 3]
in [*pre, String => x, String => y, *post]
p pre #=> ["a", 1]
p x #=> "b"
p y #=> "c"
p post #=> [2, "d", "e", "f", 3]
end
//}

* Endless method definition is added. [EXPERIMENTAL]
16746

//emlist{
def square(x) = x * x
//}

* Interpolated String literals are no lo...
...nger frozen when
`# frozen-string-literal: true` is used. 17104
* Magic comment `shareable_constant_value` added to freeze constants.
See {Magic Comments}[rdoc-ref:doc/syntax/comments.rdoc@Magic+Comments] for more details.
17273
* A {static analysis}[rdoc-label:label-Static+analysis]...
...* String#downcase
* String#dump
* String#each_char
* String#each_grapheme_cluster
* String#each_line
* String#gsub
* String#ljust
* String#lstrip
* String#partition
* String#reverse
* String#rjust
* String#rpartition
* String#r...

絞り込み条件を変える