startsWith

Syntax

startsWith(X, str)

Arguments

X is a string scalar/vector.

str is a string scalar.

Details

Check if X starts with str. If yes, return true; otherwise return false.

Examples

str1="US product"
str2="UK product"
if (startsWith(str1, "US")) print "str1 is a US product."
else print "str1 is not a US product."
if (startsWith(str2, "US")) print "str2 is a US product."
else print "str2 is not a US product.";

// output
str1 is a US product.
str2 is not a US product.