Python string matching problem

Source: Internet
Author: User

To match the <div class="back fl"><a href="javascript:void(0);" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_shangyipian‘]);location.href=‘/u012582664/article/details/56845037‘;"><span><i class="fa fa-arrow-left"></i></span><em>安装最新版python</em></a></div><div class="forward fr"><a href="javascript:void(0);" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_xiayipian‘]);location.href=‘/u012582664/article/details/59120585‘;"><em>各种数据库的注释</em><span><i class="fa fa-arrow-right"></i></span></a></div> ' 56845037 ' and ' 59120585 ' in html =, try to use the regular:

pattern_l = r‘‘‘<a href="javascript:void(0);" onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_shangyipian‘]);location.href=‘(.+?)‘;">‘‘‘re.findall(pattern_l,html)

The result is unsuccessful. Returned as NULL, useful:

 soup = BeautifulSoup(html, "lxml")        print(soup.find_all(onclick="_gaq.push([‘_trackEvent‘,‘function‘, ‘onclick‘, ‘blog_articles_shangyipian‘]);location.href=‘/u012582664/article/details/(.+?)‘;"))        

Or return empty, ask you how to write, is where the problem


Python string matching issues >> python

The answer is quite clear:
Http://www.goodpm.net/postreply/python/1010000008985846/python string matching problem. html

Python string matching problem

Related Article

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.