Answers to questions about python Regular Expressions and python Regular Expressions

Source: Internet
Author: User

Answers to questions about python Regular Expressions and python Regular Expressions

Three questions about python Regular Expressions:

1. Remove tags from the following html files and only display text information.

<Div> <p> responsibilities: </p> <p> complete recommendation algorithms, data statistics, interfaces, backend and other server-related work </p> <br> </p> <p> required requirements: </p> <p> good self-driving and professional qualities, proactive and result-oriented work </p> <br> </p> <p> technical requirements: </p> <p> 1. More than one year of Python development experience, Master object-oriented analysis and design, and understand the design mode </p> <p> 2. Master the HTTP protocol, familiar with MVC, MVVM, and other concepts and related WEB development frameworks </p> <p> 3. Master relational database development and design, Master SQL, familiar with one of MySQL/PostgreSQL <br> </p> <p> 4. Learn about NoSQL, MQ, proficient in corresponding technical solutions </p> <p> 5. Familiar with Javascript, CSS, HTML5, JQuery, React, and Vue. js </p> <br> </p> <p> additional points: </p> <p> big data, mathematical statistics, machine learning, and skle Arn, high performance, high concurrency. </P> </div>

Use the sub method in the python Regular Expression re module to replace the tag with an empty string. The Code is as follows:

#-*-Coding: UTF-8-*-import re # Remove tag s = "<div >\< p> responsibilities: </p> \ <p> complete recommendation algorithm, data statistics, interfaces, backend and other server-side work </p> \ <p> <br> </p> \ <p> required requirements: </p> \ <p> good self-driving and professional qualities, proactive and result-oriented work </p> \ <p> <br> </p> \ <p> technical requirements: </p> \ <p> 1. More than one year of Python development experience, Master object-oriented analysis and design, and understand the design mode </p> \ <p> 2. Master the HTTP protocol, familiar with MVC, MVVM, and other concepts and related WEB development frameworks </p> \ <p> 3. Master relational database development and design, Master SQL, familiar with one of MySQL/PostgreSQL <br> </p> \ <p> 4. Understanding NoSQL, MQ, proficient in corresponding technical solutions </p> \ <p> 5. Familiar with Javascript, CSS, HTML5, JQuery, React, and Vu E. js </p> \ <p> <br> </p> \ <p> additional points: </p> \ <p> big data, mathematical statistics, machine learning, sklearn, high performance, high concurrency. </P> \ </div> "p = r" </? \ W +> | "print (re. sub (p," ", s ))

2. Retrieve the domain name from the following urls:

Http://www.interoem.com/messageinfo.asp? Id = 35'
Http://3995503.com/class/class09/news_show.asp? Id = 14
Http://lib.wzmc.edu.cn/news/onews.asp? Id = 769
Http://www.zy-ls.com/alfx.asp? Newsid = 377 & id = 6
Http://www.fincm.com/newslist.asp? Id = 415

Use the sub method to replace the entire string with a string containing only domain names. The Code is as follows:

#-*-Coding: UTF-8-*-import re # extract domain name s2 = "http://www.interoem.com/messageinfo.asp? Id = 35 'HTTP: // 3995503.com/class/class09/news_show.asp? Http://lib.wzmc.edu.cn/news/onews.asp? Id = 769 http://www.zy-ls.com/alfx.asp? Newsid = 377 & id = 6 http://www.fincm.com/newslist.asp? Id = 415 "p = r" (http: //. +? /). + "Print (re. sub (p, lambda x: x. group (1), s2 ))

3. Extract the words in the following string:

hello world ha ha

Use the split method to separate spaces or use the findall method to find all words. The Code is as follows:

#-*-Coding: UTF-8-*-import re # extract the word s3 = "hello world ha ha" print (re. split (r "+", s3) print (re. findall (r "\ B \ w + \ B", s3 ))

The running results of the three questions are as follows:

Question 1:

Responsibilities: complete recommendation algorithms, data statistics, interfaces, backend and other server-related requirements: good self-driving and professional qualities, proactive and result-oriented technical requirements: 1. More than one year of Python development experience, understanding Object-Oriented Analysis and Design, understanding the design mode 2, understanding the HTTP protocol, familiar with MVC, MVVM, and other concepts and related WEB development frameworks 3. Master relational database development and design, Master SQL, and master one of MySQL/PostgreSQL 4. Master NoSQL and MQ, familiar with corresponding technical solutions 5. Familiar with Javascript/CSS/HTML5, JQuery, React, and Vue. js bonus points: big data, mathematical statistics, machine learning, sklearn, high performance, and high concurrency.

Question 2:

Http://www.interoem.com/
Http://3995503.com/
Http://lib.wzmc.edu.cn/
Http://www.zy-ls.com/
Http://www.fincm.com/

Question 3:

['Hello', 'World', 'ha', 'ha']
['Hello', 'World', 'ha', 'ha']

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.