In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Regular expressions are powerful, but it takes you some time to master them.
The following explains the common methods of match, compile, search and findall
Match
Match starts with the first character of the string. If it does not match to return None, it returns an object.
Did not match to return None
The starting character matches to h, and an object is returned, and the h value needs to be obtained through group.
Search
Search is somewhat similar to match, except that searching the entire string and then the first match to the specified character returns a value, and if it does not match, it returns None. To get a worthwhile method, you also need to use group ()
Returns None if it does not match the character
Match back from the string, and an object is returned as soon as the match is reached. The matching value needs to be obtained through group.
Findall
Findall matches all the values in the string related to the specified value and returns as a list. If it does not match, an empty list is returned.
Did not match to return an empty list.
Matches all values of the specified character and returns values as a list.
Compile
Re.compile converts regular expressions into pattern objects so that they can match more efficiently. After using compile to convert once, you don't have to convert each time you use the pattern in the future
In fact, this is the same result as executing re.findall ('img',a), except that after using compile, you don't need to convert the schema object again when you execute the findall method.
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.