endswith
stringChecks if a string ends with a specific suffix
Syntax
endswith(string, suffix) Parameters
string (string) The string to check
suffix (string) The suffix to look for
Returns
boolean True if string ends with suffix, false otherwise
Examples
Input:
endswith("file.txt", ".txt") Output:
true Input:
endswith("document.pdf", ".txt") Output:
false Input:
"image.png" | endswith(".png") Output:
true The endswith() function checks whether a string ends with a specified suffix. Returns true if it does, false otherwise.
Usage
Use endswith() to filter files by extension, validate formats, or check string patterns. Commonly used for file type validation and filtering.