るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

String#delete_suffix(suffix) -> String (24220.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 (12220.0)

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

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

@param 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#delete_prefix!(prefix) -> self | nil (6107.0)

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

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

@param 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?...

String#delete_prefix(prefix) -> String (6107.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#end_with?(*strs) -> bool (113.0)

self の末尾が strs のいずれかであるとき true を返します。

...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#chomp!(rs = $/) -> self | nil (107.0)

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

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

rs に nil を指定した場合、この...
...("\r\n", "\n")をすべて取り除きます。

@return chomp! は通常 self を返しますが、取り除く改行がなかった場合は nil を返します。

//emlist[例][ruby]{
buf = "string\n"
buf.chomp! # => nil
p buf # => "string"

$/ = "\n" # デフォルトと同じ
p "foo\r...
...# => "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#chop! -> self | nil (107.0)

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

...self を変更して返しますが、取り除く文字がなかった場合は 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!...