string.startswith Function |
The string.startswith function determines whether a given string starts with a second string.
string.startswith(str, cmp);
str | A string expression |
cmp | A string expression to compare with the start of str |
True if str starts with cmp, otherwise returns false. The test is case-sensitive.
$myString = "Telogis"; PRINT string.startswith($myString, "Tel"); PRINT string.startswith($myString, "tel"); PRINT string.startswith($myString, "ted");
The above code snippet produces the following output:
True False False |
The string.startswith function is commonly used when importing data to ensure names are correctly formatted:
IMPORT STREETS [ ID = %id, ... NAME = string.startswith(%fullname, "I ") ? "I-" + substring(%fullname, 2) : string.startswith(%fullname, "Hwy ") ? "SR-" + substring(%fullname, 4) : %fullname, ... ]