In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is a detailed introduction to "What is the difference between re.match and re.search in Python 3". The content is detailed, the steps are clear, and the details are properly handled. I hope this article "What is the difference between re.match and re.search in Python 3" can help you solve your doubts. Let's go deeper and learn new knowledge together with the ideas of Xiaobian.
Difference between re.match and re.search.
re.match matches only the beginning of the string, if the beginning of the string does not match the regular expression, the match fails, the function returns None, and re.search matches the entire string until a match is found.
examples
#!/ usr/bin/python3
import re
line = "Cats are smarter than dogs"
matchObj = re.match( r'dogs', line, re.M|re.I)
if
matchObj:
print ("match --> matchObj.group() : ", matchObj.group())
else:
print ("No match!! ") matchObj = re.search( r'dogs', line, re.M|re.I)
if
matchObj:
print ("search --> matchObj.group() : ", matchObj.group())
else:
print ("No match!! ")
The results of the above examples are as follows:
No match!! search --> matchObj.group () : dogs Read here, this article "Python3 re.match and re.search is the difference between" article has been introduced, want to master the knowledge of this article also need to practice to understand, if you want to know more about the content of the article, welcome to pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.