logo
  • 教程列表
  • SO官方文檔
  • 字串
    • 單引號和雙引號字串文字之間的區別
    • 建立一個字串
    • 案件操作
    • 字串連線
    • 拆分字串
    • 定位字串
    • 加入字串
    • 字串以。開頭
    • 字串插值
    • 字串以。結尾
    • 多行字串
    • 格式化字串
    • 字串字元替換
    • 理解字串中的資料
    • 字串替換
  1. StackOverflow 文件
  2. Ruby Language 教程
  3. 字串
  4. 字串以。開頭

字串以。開頭

Created: November-22, 2018

要查詢字串是否以模式開頭,start_with? 方法會派上用場

str = "zebras are cool"
str.start_with?("zebras")      => true

你還可以使用 index 檢查圖案的位置

str = "zebras are cool"
str.index("zebras").zero?      => true
  • 字串插值
  • 加入字串

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明