Docly Developers
Function Updated 13 Nov 2023

String.startsWith(text)

Searches the start of the string, and returns a boolean that is True if the string starts with this text otherwise False.

Parameters

textstringrequired

Sub string to check if string starts with. Case sensitive.

Returns

True if the string starts with the specified text otherwise False.

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
    var text = "This is a test";
    var search = "This";
    var notfound = "xyz";
}#

<b>Starts with '#search#', result:</b>
#{
    var result = text.startsWith(search);
    write(result);
}#


<b>Not starts with '#notfound#', result:</b>
#{
    result = text.startsWith(notfound);
    write(result);    
}#