Python Regular Expressions

Source: Internet
Author: User

#-*-coding:utf-8-*-import Re#match: Matches the string from the beginning of the string, if it is matched to return an object that does not match the return noneres= Re.match ("test.","Testasdwoedhello") Print (res) #获取 matching string print (Res.group ()) #从整个文本开始搜索sr= Re.search ("D.+d","Testasdwoedhello") Print (Sr.group ()) #返回所有fa= Re.findall ("[0-9]{1,3}","TESDA123STASDWOE435DHELLO667DAASDD") print (FA) #分割print (Re.split ("[0-9]","Asdasd1dads222dasd21")) #替换print (Re.sub ("[0-9]","AAA","wer1azx2vff22"))

Python Regular Expressions

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.