Table of Contents
Introduction
The task is to check whether the string ends with alphanumeric charters or not.
Program
import re def check(ip_str): re_exp = '[a-zA-z0-9]$' if(re.search(re_exp, ip_str)): return "The string is ending with alphanumeric char!" else: return "The string does not ends with alphanumeric char!" ip_str = input("Enter the string: ") print(check(ip_str))
Output
Explanation
In the above python code, the regular expression we have used is ‘[a-zA-Z0-9]$’. The symbol $ signifies the end with character. We have implied the expression on our input and checked whether it satisfies it or not and printed the output accordingly.
0 Comments