Python Regular Expression re

Source: Internet
Author: User

Python Regular Expression re
Import rere. the compile () function is used to compile the regular expression string form into a Pattern instance, and then use the Pattern instance to process the text and obtain the matching result m = re. search (pattern, string) # search the entire string until the matching sub-string m = re is found. match (pattern, string) # Check whether the string conforms to the regular expression from the beginning. The returned m must start with the first character of the string. We use m. group () to call the result. M. group (number) method to query a group. Group (0) is the search result of the entire regular expression, and group (1) is the first group ...... Re. split () # split the string according to the regular expression, put all the substrings after the split in a table (list), and return re. findall () # search for a string based on a regular expression, and put all matching substrings in a list to return the re. S # indicates multi-row matching, using re. after the S parameter, the regular expression matches the string as a whole.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.