Python regular Match search FindAll

Source: Internet
Author: User

Match : Match only once, the start match does not go up, then does not continue matching a,b,\w+Match (A, "abcdef") matches a>>> Re.match ("A", "abcdef"). Group () ' A ' match (b, "abcdef") >>> print Re.match ("b "," abcdef ") Nonematch (" \w+ "," abcdef ")search, full string match, but match only once, match does not continue to match a, b,\w+>>> Re.search ("A", "ABCDEF ABC 123 456"). Group () ' A ' >>> re.search ("B", "ABCDEF ABC 123 456"). Group () ' B ' >>> re.search ("\w+", "abcdef ABC 123 456"). Group () ' ABCdef 'FindAllNote: findall return list, List cannot group ()>>> Print Re.findall (r "B", "ABCDEF ABC 123 456") [' B ', ' B '] >>> print Re.findall (r "a", "ABCDEF ABC 123 456") ) [' A ', ' a '] >>> print Re.findall (r "\w+", "abcdef ABC 123 456") [' abcdef ', ' abc ', ' 123 ', ' 456 ']

Python regular Match search FindAll

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.