るりまサーチ

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

別のキーワード

  1. _builtin delete
  2. _builtin delete_if
  3. cgi delete
  4. net/pop delete_all
  5. pop3 delete_all

ライブラリ

クラス

検索結果

String#delete_suffix(suffix) -> String (39250.0)

文字列の末尾から suffix を削除した文字列のコピーを返します。

...

@return 文字列の末尾から suffix を削除した文字列のコピー

//emlist[][ruby]{
"hello".delete_suffix("llo") # => "he"
"hello".delete_suffix("hel") # => "hello"
//}

@see String#chomp
@see String#chop
@see String#delete_prefix
@see String#delete_suffix!
@see String#end_with?...

String#delete_suffix!(suffix) -> self | nil (27149.0)

self の末尾から破壊的に suffix を削除します。

...ます。

@return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_suffix!("llo") # => "he"
"hello".delete_suffix!("hel") # => nil
//}

@see String#chomp!
@see String#chop!
@see String#delete_prefix!
@see String#delete_suffix
@see String#end_with?...

String#chop -> String (21155.0)

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

...ばその 2 文字を取り除きます。

//emlist[例][ruby]{
p "string\n".chop # => "string"
p "string\r\n".chop # => "string"
p "string".chop # => "strin"
p "strin".chop # => "stri"
p "".chop # => ""
//}

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

String#chomp(rs = $/) -> String (21137.0)

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

...# => "foo"
p "foo\n".chomp # => "foo"
p "foo\n\r".chomp # => "foo\n"

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

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

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

String#delete_prefix(prefix) -> String (21125.0)

文字列の先頭から prefix を削除した文字列のコピーを返します。

...する文字列を指定します。

@return 文字列の先頭から prefix を削除した文字列のコピー

//emlist[][ruby]{
"hello".delete_prefix("hel") # => "lo"
"hello".delete_prefix("llo") # => "hello"
//}

@see String#delete_prefix!
@see String#delete_suffix
@see String#start_with?...

絞り込み条件を変える

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

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

..."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!
@see String#delete_suffix!...

String#end_with?(*strs) -> bool (21048.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#chop! -> self | nil (21042.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#delete_prefix!(prefix) -> self | nil (21024.0)

self の先頭から破壊的に prefix を削除します。

...ら削除する文字列を指定します。

@return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_prefix!("hel") # => "lo"
"hello".delete_prefix!("llo") # => nil
//}

@see String#delete_prefix
@see String#delete_suffix!
@see String#start_with?...

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]...
...yield String instances instead of subclass instances when called on subclass instances: 10845
* String#*
* String#capitalize
* String#center
* String#chomp
* String#chop
* String#delete
* String#delete_prefix
* String#delete_suffix
* String#down...

絞り込み条件を変える

NEWS for Ruby 2.5.0 (114.0)

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

...onSequence#trace_points を追加

* String
* String#-@ はフリーズされていない文字列の重複を排除します。
互換性のため、既にフリーズされている文字列には何もしません。 13077
* -"literal" (String#-@) は同じオブジェクトを...
...3295
* String#casecmp, String#casecmp? に文字列でない引数を与えた場合、TypeErrorを発生させずにnilを返すようにしました
13312
* String#start_with? は正規表現を受け取れるようになりました 13712
* String#delete_prefix, String#delete_pr...
...efix! を追加 12694
* String#delete_suffix, String#delete_suffix! を追加 13665
* String#each_grapheme_cluster, String#grapheme_clusters を追加。結合文字を列挙します。
13780
* String#undump を追加。String#dumpで出力した文字列を元に戻します。12...