Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Regular Expression In Python

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 958
    Comment on it

    Hi All,

    Regular expression is used to validate input. Python have a library which have many methods to use regular expression.

    Regular Expression :- A regular expression (or RE) specifies a set of strings that matches it.

    The functions in re library of python, let you check if a particular string matches a given regular expression (or if a given regular expression matches a particular string).

    Email Validation using RE :-

    def emailValidation():
    	email = input("enter the mail address::")
    	match = re.search(r'[\w.-]+@[\w.-]+.\w+', email)
    	if match :
    		print("success")
    	else:
    		print("failed")

    Before above code just import re , you can validate any string just pass regular expression and object that contain value to search method , it will return you boolean value ,true if matches otherwise false.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: