string_ends_with

This function checks if a string ends with a given substring. It returns true if it does, or false if it doesn't.

 

Syntax:

string_ends_with(str, substr);

ArgumentTypeDescription
strStringThe string to check for the occurrence of the given substring at the end
substrStringThe substring that the string should end with

 

Returns:

Boolean

 

Example:

var _message = "Hello World.";
if string_ends_with(_message, ".") || string_ends_with(_message, "?") || string_ends_with(_message, "!")
{
    show_debug_message("The message is a valid sentence.");
}

The above code first defines a string and stores it in a temporary variable _message. It then makes three calls to the function string_ends_with to check if the string ends with one of the following three punctuation marks: ".", "?" or "!". If the message ends in any of those, it shows a debug message.