Match the start of a string
Check the letters at the start of the text. The result is true only when those letters match.
startswith
Simple example
Does abc start with a?
Start'abc' · 'a'
Resulttrue
function main()
println(startswith("abc", "a"))
end
main()
true
Advertisements
Everyday examples
Child tickets start with C-. Is this a child ticket?
Start'C-18' · 'C-'
Resulttrue
function main()
println(startswith("C-18", "C-"))
end
main()
true
Express parcels start with EX. Should this parcel go in the express tray?
Start'BX42' · 'EX'
Resultfalse
function main()
println(startswith("BX42", "EX"))
end
main()
false
Is this shelf in the LAB section?
Start'LAB-3' · 'LAB'
Resulttrue
function main()
println(startswith("LAB-3", "LAB"))
end
main()
true