The following editor will bring you an article on how to use re in Python (detailed explanation). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.
1: re.search():search returns the object of the search result, you can use group() or groups () method to get the successfully matched string.
①group() The entire string that matches successfully is returned by default (ignoring the brackets in pattern). You can also specify which character in the brackets to return that matches successfully. String (counting from 1);
②groups() Returns the content in the brackets of the successfully matched pattern in the form of a tuple, if there are no brackets in the pattern , then an empty tuple is returned.
The above is the detailed content of Analyze Python's re operation method. For more information, please follow other related articles on the PHP Chinese website!