This function checks if a string ends with a given substring. It returns true if it does, or false if it doesn't.
string_ends_with(str, substr);
Argument | Type | Description |
---|---|---|
str | String | The string to check for the occurrence of the given substring at the end |
substr | String | The substring that the string should end with |
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.