Run
import re my_string = "Hello, World!" suffix_to_check = "World!" pattern = re.escape(suffix_to_check) + "$" if bool(re.search(pattern, my_string)): print('Given string ends with specified suffix.') else: print('Given string does NOT end with specified suffix.')
Output