LoginSignup
0
0

More than 3 years have passed since last update.

Ruby 変数に格納された文字列の開始文字数と終了文字数を指定して表示する

Posted at

目的

  • 変数に格納された文字列の開始文字数と終了文字数を指定して表示する方法をまとめる

書き方の例

  • 下記に変数Aに格納された文字列を開始文字数と終了文字数を指定して表示する方法を記載する。

    puts 変数A.slice(開始文字数..終了文字数)
    

より具体的な書き方の例

  • 変数todayに格納された文字列の0文字目から10文字目までを表示する方法を記載する。

    today = "2020-02-04 09:01:35"
    puts today.slice(0..10)
    2020-02-04
    
0
0
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
0
0