1# Python program to identify the identifier
2
3# import re module
4
5# re module provides support
6# for regular expressions
7import re
8
9# Make a regular expression
10# for identify valid identifier
11regex = '^[A-Za-z_][A-Za-z0-9_]*'
12
13# Define a function for
14# identifying valid identifier
15def check(string):
16
17 # pass the regualar expression
18 # and the string in search() method
19 if(re.search(regex, string)):
20 print("Valid Identifier")
21
22 else:
23 print("Invalid Identifier")
24
25
26# Driver Code
27if __name__ == '__main__' :
28
29 # Enter the string
30 string = input("Enter you Identifier\n")
31 # calling run function
32 check(string)