Question whether a string ends with a substring
string:ends_with?(STRING $string, STRING $substring) : BOOL
string:ends_with?('hi friend','friend')
#=> TRUE
string:ends_with?('hello world!','!')
#=> TRUE
string:ends_with?('hello world!','!!')
#=> FALSE
# it is case sensitive
string:ends_with?('hello world!','WORLD!')
#=> FALSE
# empty substring will return TRUE
string:ends_with?('hello world!','')
#=> FALSE
# you can check for spaces too
string:ends_with?('hello world! ',' ')
#=> TRUE
string:ends_with?('hello world!0',0)
#=> TRUE
# newline characters
string:ends_with?('hello world!',"\n")
#=> FALSE
Copyright ©2013-2022 SunSed®. All rights reserved.