Skip to content

Instantly share code, notes, and snippets.

@mistyrinth
Created November 28, 2018 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mistyrinth/a97e1ea32ef8e61b560c9615af8945fc to your computer and use it in GitHub Desktop.
Save mistyrinth/a97e1ea32ef8e61b560c9615af8945fc to your computer and use it in GitHub Desktop.
str = "Welcome"
puts "元の文字列は #{str} です"
# 文字列の挿入
ins = str.insert(3,"yes")
puts "3番目の位置に yes を挿入すると #{ins} です"
# 文字列の検索
str = "Welcome"
pos = str.index("co")
puts "co を検索した結果、左からの位置は #{pos} 番目です"
puts "come が含まれているかどうかの結果は #{str.include?("come")} です"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment