Analyze Python's re operation method

巴扎黑
Release: 2017-08-08 14:44:38
Original
1437 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template