Function Updated 13 Nov 2023
String.endsWith(text)
Searches the end of the string, and returns a boolean that is True if the string ends with this text otherwise False.
Parameters
textstringrequiredSub string to check if string ends with. Case sensitive.
Returns
True if the string ends 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 = "test";
var notfound = "xyz";
}#
<b>Ends with '#search#', result:</b>
#{
var result = text.endsWith(search);
write(result);
}#
<b>Not ends with '#notfound#', result:</b>
#{
result = text.endsWith(notfound);
write(result);
}#The template above produces this output:
<b>Ends with 'test', result:</b>
true
<b>Not ends with 'xyz', result:</b>
false