xxxxxxxxxx
import regex as re
string = "hello world"
# Check if the string ends with "world"
if re.search(r"world$", string):
print("The string ends with 'world'.")
else:
print("The string does not end with 'world'.")
xxxxxxxxxx
import re
str = 'Python is a programming language'
#search using regex
x = re.search('programming$', str)
if(x!=None):
print('The line ends with \'programming\'.')
else:
print('The line does not end with \'programming\'.')