首页 > 编程语言 > 详细

Python最新答案

时间:2020-05-05 16:46:41      阅读:76      评论:0      收藏:0      [点我收藏+]
import re
# 文本
telNumber = ‘‘‘Suppose my Phone No. is 0535-1234567, yours is 010-12345678, his is 025-87654321. ‘‘‘
# 正则表达式模式
regular = re.compile(r\d+-\d+)
tel_list = re.findall(regular,telNumber)
tel_str = \n.join(tel_list)
print(tel_str)

str= ‘‘‘ dgned@123.com   sdfadf@.com  efddfd124@180.com df2dhtd@123.com  dflfdfi@139.com  feffzd.com defgdf@.sodf.com.com ‘‘‘
regular = re.compile(r\w*\d*[@]\w+.com|\w*\d*[@]\d+.com)
email_list = re.findall(regular,str)
email_str = \n.join(email_list)
print(email_str)

str=aldb153   2019-03-26 14:30:00 2019-03-12 09:30:10
regular = re.compile(r\d{4}[-]\d{2}[-]\d{2} \d{2}[:]\d{2}[:]\d{2})
date_list = re.findall(regular,str)
date_str = \n.join(date_list)
print(date_str)

str=The shortest way 124 to do many 23111 things is to do 1689 only one thing 246 at a time
regular = re.compile(r[a-zA-Z]+\b)
word_list = re.findall(regular,str)
word_str = \n.join(word_list)
print(word_str)

str = ‘‘‘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‘‘‘
    
regular = re.compile(rhttp://\b|/[a-z0-9.?=/_&]+\b)    
domain_name = re.sub(regular,"",str)    
domain_str = "".join(domain_name)    
print(domain_str)

 

Python最新答案

原文:https://www.cnblogs.com/angoli/p/12830538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!