RosettaCodeData/Task/String-matching/Scala/string-matching.scala

9 lines
282 B
Scala
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
"abcd".startsWith("ab") //returns true
"abcd".endsWith("zn") //returns false
"abab".contains("bb") //returns false
"abab".contains("ab") //returns true
var loc="abab".indexOf("bb") //returns -1
loc = "abab".indexOf("ab") //returns 0
loc = "abab".indexOf("ab", loc+1) //returns 2