るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

String#strip -> String (24287.0)

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

...\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 #=> "\ta...
...bc\n" (元の文字列は変化しない)
//}

@see String#lstrip, String#rstrip...

String#strip! -> self | nil (12269.0)

先頭と末尾の空白文字を全て破壊的に取り除きます。 空白文字の定義は " \t\r\n\f\v\0" です。

...f\v\0" です。

strip
! は、内容を変更した self を返します。
ただし取り除く空白がなかったときは nil を返します。

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

str = "abc"
p
str.strip! #=> nil
p
str...
...#=> "abc"

str = " \0 abc \0"
str.strip!
p
str #=> "abc"
//}

@see String#strip, String#lstrip...

String#rstrip -> String (12250.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#lstrip,S...
...tring#strip...

String#lstrip -> String (12232.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#lstrip! -> self | nil (12232.0)

文字列の先頭にある空白文字を全て破壊的に取り除きます。 空白文字の定義は " \t\r\n\f\v\0" です。

...t\r\n\f\v\0" です。

lstrip! は self を変更して返します。
ただし取り除く空白がなかったときは nil を返します。

//emlist[例][ruby]{
str = " abc"
p
str.lstrip! # => "abc"
p
str # => "abc"

str = "abc"
p
str.lstrip! # => nil
p
str # => "abc...

絞り込み条件を変える

String#rstrip! -> self | nil (12232.0)

文字列の末尾にある空白文字を全て破壊的に取り除きます。 空白文字の定義は " \t\r\n\f\v\0" です。

...的に取り除きます。
空白文字の定義は " \t\r\n\f\v\0" です。

//emlist[例][ruby]{
str = " abc\n"
p
str.rstrip! # => " abc"
p
str # => " abc"

str = " abc \r\n\t\v\0"
p
str.rstrip! # => " abc"
p
str # => " abc"
//}

@see String#rstrip, String#lstrip...

String#parse_csv(**options) -> [String] (6222.0)

CSV.parse_line(self, options) と同様です。

...CSV.parse_line(self, options) と同様です。

1 行の CSV 文字列を、文字列の配列に変換するためのショートカットです。

@param options CSV.new と同様のオプションを指定します。

//emlist[][ruby]{
require "csv"

p
"Matz,Ruby\n".parse_csv...
..."Ruby"]
p
"Matz|Ruby\r\n".parse_csv(col_sep: '|', row_sep: "\r\n") # => ["Matz", "Ruby"]
//}

Ruby
2.6 (CSV 3.0.2) から、次のオプションが使えるようになりました。

//emlist[][ruby]{
require 'csv'

p
"1,,3\n".parse_csv # => ["1", nil, "3"]
p
"1,,3\n".par...
..."3"]
//}

Ruby
2.7 (CSV 3.1.2) から、次のオプションが使えるようになりました。

//emlist[][ruby]{
require 'csv'

p
"Matz, Ruby\n".parse_csv # => ["Matz", " Ruby"]
p
"Matz, Ruby\n".parse_csv(strip: true) # => ["Matz", "Ruby"]
//}

@see CSV.new, CSV.parse_lin...