20 lines
456 B
Text
20 lines
456 B
Text
s1 = "string"
|
|
s2 = "str"
|
|
s3 = "ing"
|
|
s4 = "xyz"
|
|
|
|
println["$s1 starts with $s2: " + startsWith[s1, s2]]
|
|
println["$s1 starts with $s4: " + startsWith[s1, s4]]
|
|
println["$s1 ends with $s3: " + endsWith[s1, s3]]
|
|
println["$s1 ends with $s4: " + endsWith[s1, s4]]
|
|
position[s1, s2]
|
|
position[s1, s4]
|
|
|
|
position[s1, s2] :=
|
|
{
|
|
pos = indexOf[s1,s2]
|
|
if pos == -1
|
|
println["$s1 does not contain $s2"]
|
|
else
|
|
println["$s1 contains $s2 at position $pos"]
|
|
}
|