5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruby文字列メソッド

Last updated at Posted at 2015-01-26

String#capitalize

文字列の先頭を大文字に、残りを小文字に変更

String#upcase/downcase

upcaseで文字列を全て大文字に変更
downcaseで文字列を全て小文字に変更

String#swapcase

文字列のアルファベットの大文字・小文字を入れ替え

String#strip/#lstrip/#rstrip

空白文字の除去
strip 空白文字を全て削除
lstrip 後方の空白文字を削除
rstrip 前頭の空白文字

String#each_char

文字列を1文字ずつ取り出す。

String#each_line

文字列を1行ずつ取り出す。

String#chars

文字列の分解・連結・挿入・逆転
文字列を文字ごとに分解して配列に直す

String#lines

複数行の文字列を行ごとに分解して配列に直す

+

演算子を使う文字列の連結方法

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?