ライブラリ
- ビルトイン (103)
キーワード
- chomp (7)
- chomp! (7)
- chop (7)
- chop! (7)
- delete! (11)
-
delete
_ prefix (7) -
delete
_ prefix! (7) -
delete
_ suffix (7) -
delete
_ suffix! (7) -
end
_ with? (7) -
start
_ with? (7) - unpack (11)
検索結果
先頭5件
-
String
# delete(*strs) -> String (21338.0) -
self から strs に含まれる文字を取り除いた文字列を生成して返します。
...self から strs に含まれる文字を取り除いた文字列を生成して返します。
str の形式は tr(1) と同じです。
つまり、`a-c' は a から c を意味し、"^0-9" のように
文字列の先頭が `^' の場合は指定文字以外を意味します。
「-」は文......合は、
すべての引数にマッチする文字だけが削除されます。
@param strs 削除する文字列を示す文字列 (のリスト)
//emlist[例][ruby]{
p "123456789".delete("2378") #=> "14569"
p "123456789".delete("2-8", "^4-6") #=> "14569"
//}
@see String#delete!... -
String
# delete _ suffix(suffix) -> String (9268.0) -
文字列の末尾から suffix を削除した文字列のコピーを返します。
...
@param 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 _ prefix(prefix) -> String (9256.0) -
文字列の先頭から prefix を削除した文字列のコピーを返します。
...
@param 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
# delete!(*strs) -> self | nil (9250.0) -
self から strs に含まれる文字を破壊的に取り除きます。
...self から strs に含まれる文字を破壊的に取り除きます。
str の形式は tr(1) と同じです。
つまり、「a-c」は a から c を意味し、"^0-9" のように
文字列の先頭が「^」の場合は指定文字以外を意味します。
「-」は文字列の両端......れます。
@return 通常は self を返しますが、何も変更が起こらなかった場合は nil を返します。
@param strs 削除する文字列を示す文字列 (のリスト)
//emlist[例][ruby]{
str = "123456789"
p str.delete!("2378") #=> "14569"
p str......#=> "14569"
str = "123456789"
p str.delete!("2-8", "^4-6") #=> "14569"
p str #=> "14569"
str = "abc"
p str.delete!("2378") #=> "nil"
p str #=> "abc"
//}
@see String#delete... -
String
# delete _ suffix!(suffix) -> self | nil (9168.0) -
self の末尾から破壊的に 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#d......elete_prefix!
@see String#delete_suffix
@see String#end_with?... -
String
# delete _ prefix!(prefix) -> self | nil (9156.0) -
self の先頭から破壊的に 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_suffi......x!
@see String#start_with?... -
String
# end _ with?(*strs) -> bool (3131.0) -
self の末尾が strs のいずれかであるとき true を返します。
...strs のいずれかであるとき true を返します。
@param strs パターンを表す文字列 (のリスト)
//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
//}
@see String#st......art_with?
@see String#delete_suffix, String#delete_suffix!... -
String
# chomp(rs = $ / ) -> String (3125.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
# chop -> String (3125.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
# unpack(template) -> Array (3049.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...アンパックし、
それらの要素を含む配列を返します。
@param template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるものは、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文......t
i,i!: signed int
I,I!: unsigned int
l!: signed long
L!: unsigned long
q!: signed long long
Q!: unsigned long long
j,j!: intptr_t
J,J!: uintptr_t
//}
: エンディアン依存、整数サイズ非依存 (C99 の stdint.h にある厳密な幅を持つ整数型に適切)
//emlist{......0\x00by".unpack('ccxxcc') # => [82, 117, 98, 121]
//}
: Hexダンプを数値の配列に変換する例
//emlist[][ruby]{
"61 62 63 64 65 66".delete(' ').lines.pack('H*').unpack('C*')
# => [97, 98, 99, 100, 101, 102]
"61 62 63 64 65 66".split.collect {|c| c.hex}
# => [97, 98, 99, 100, 101, 102......ックし、
それらの要素を含む配列を返します。
@param template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるものは、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレ... -
String
# chomp!(rs = $ / ) -> self | nil (3031.0) -
self の末尾から rs で指定する改行コードを取り除きます。 ただし rs が "\n" ($/ のデフォルト値) のときは、 実行環境によらず "\r", "\r\n", "\n" のすべてを改行コードとみなして取り除きます。
...("\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 (3031.0) -
文字列の最後の文字を取り除きます。 ただし、終端が "\r\n" であればその 2 文字を取り除きます。
...ます。
@return chop! は self を変更して返しますが、取り除く文字がなかった場合は nil を返します。
//emlist[例][ruby]{
str = "string\r\n"
ret = str.chop!
ret # => "string"
str # => "string"
str.chop! # => "strin"
"".cho......p! # => nil
//}
@see String#chomp!
@see String#chop
@see String#delete_suffix!... -
String
# start _ with?(*prefixes) -> bool (3031.0) -
self の先頭が prefixes のいずれかであるとき true を返します。
...るとき true を返します。
@param prefixes パターンを表す文字列または正規表現 (のリスト)
//emlist[例][ruby]{
"string".start_with?("str") # => true
"string".start_with?("ing") # => false
"string".start_with?("ing", "str") # => true
"string".start_wit......h?(/\w/) # => true
"string".start_with?(/\d/) # => false
//}
@see String#end_with?
@see String#delete_prefix, String#delete_prefix!...