How do I match exact words in Python?

Using regular expressions to match exact words in python.

What is RegEx(Regular Expressions): A RegEx, or Regular Expression, maybe a sequence of characters that forms a search pattern.

RegEx can be used to check whether a string contains a specified search pattern or not.

Python has an in-built package called re module. re module works as a regular expression.

Firstly, Import the re module


  1. import re 
  2. str = "This is python re module" 
  3. x = re.search("re", str) 
  4. if x: 
  5. print("YES! We have a match!") 
  6. else: 
  7. print("No match") 

Comments

Popular posts from this blog

proassignment help backlink data index 41

programming shark backink data index 31

Programming shark backlink data index 67