当前位置: 首页 > news >正文

怎么做带数据库的网站如何创建网站平台

怎么做带数据库的网站,如何创建网站平台,企业管理咨询与诊断实践报告,九一人才网赣州文章目录 前言一、正则对象是什么?二、正则表达式基本分类1.普通字符2.元字符 总结 前言 很开心能和你们一些学习进步,在这一个多月的时间中,是你们让我坚持了下来,完成了python基础课堂编写,不管如何,我们…

文章目录

  • 前言
  • 一、正则对象是什么?
  • 二、正则表达式基本分类
    • 1.普通字符
    • 2.元字符
  • 总结


前言

很开心能和你们一些学习进步,在这一个多月的时间中,是你们让我坚持了下来,完成了python基础课堂编写,不管如何,我们或多或少都会有所收获,到此,基础课堂也就告一段落了。在不久的将来我将会进行爬虫栏目的编写,感兴趣的uu可以提前关注我,让我们继续学习进步!!!


一、正则对象是什么?

正则对象是在使用正则表达式时创建的对象。它可以用来进行字符串匹配、替换、提取等操作。正则对象包含了正则表达式的模式以及一些可选的标志,可以根据这些模式和标志来进行匹配操作。

接下来让我们详细了解一下正则表达式吧

介绍:在实际开发过程中经常会有查找符合某些复杂规则的字符串的需要,比如:邮箱、图片地址,手机号码等,这时候想匹配或者查找符合某些规则的字符串就可以使用正则表达式了。

概念:正则表达式就是记录文本规则的代码

表达式: 0\d{2}-\d{8}这个就是一个正则表达式,表达的意思是匹 配的是座机号码。

优缺点
1. 正则表达式的语法很令人头疼﹐可读性差
2. 正则表达式通用性很强﹐能够适用于很多编程语言

二、正则表达式基本分类

1.普通字符

见名知意,就是想要找到那个字符就直接输入该字符即可,比较简单常见,这里就不再过多介绍了。

2.元字符

  1. 匹配单个字符

分类:(在这里需要用到re模块,使用的时候下载导入即可)
元字符的分类
代码如下(示例):

print(re.findall('.', 'hello Abner world 123'))  # ['h', 'e', 'l', 'l', 'o', ' ', 'A', 'b', 'n', 'e', 'r', ' ', 'w', 'o', 'r', 'l', 'd', ' ', '1', '2', '3']
print(re.findall('\w', 'hello Abner world 123__'))  # ['h', 'e', 'l', 'l', 'o', 'A', 'b', 'n', 'e', 'r', 'w', 'o', 'r', 'l', 'd', '1', '2', '3', '_', '_']
print(re.findall('\s', 'hello Abner world 123'))  # [' ', ' ', ' ']
print(re.findall('\d', 'hello Abner world 123'))  # ['1', '2', '3']
print(re.findall('\n', 'hello Abner \n world 123'))  # ['\n']
print(re.findall('\t', 'hello Abner world 123'))  #[]
print(re.findall('\d{11}', '我的电话号码是:12345678901'))  # ['12345678901']
print(re.findall('[^0-9]', '我的电话号码是:12345678901'))  # ['我', '的', '电', '话', '号', '码', '是', ':']
print(re.findall('[0-9]', '我的电话号码是:12345678901'))  # ['1', '2', '3', '4', '5', '6', '7', '8', '9', '1', '0']
  1. 匹配多个字符(需要用到量词)

量词:控制元字符出现的次数
量词
代码如下(示例):

# 注意:量词都只作用于前一个字符
# 1 *:前一个字符重复0次或更多次
res = re.findall('b*','abbbbbbabbbbabbab')
print(res)# 2 +:前一个字符最少出现一次,最多任意次
res = re.findall('b+','abbbbbbabbbbabbab')
print(res)# 3 ?:前一个字符最少出现0次,最多只重复一次
res = re.findall('b?','abbbbbbabbbbabbab')
print(res)# 4 {n}:前一个字符匹配n次
# {n,}:前一个字符匹配n次或更多次,最少匹配n次,大于n次会匹配到
# {n,m}:前一个字符最少出现n次,最多出现m次。 只在范围内res = re.findall('1\d{10}','16451556455')
print(res)
  1. 匹配开头和结尾
# 1  ^ 匹配固定字符的开始
res = re.findall('^1\d{10}','16451556455')
print(res)
# 2  $ 匹配固定字符串的结尾
tel_li = ['15875845987','19945857694','17586945698','17584593658']
for tel in tel_li:res = re.findall('^1\d{9}8$',tel)if res:print(res[0])# 3 a|b  匹配字符a或b
# 注意:|是分开的两个表达式
res = re.findall('\d{6,10}@qq|sina.com','1258458@qq.com  594554@sina.com')
print(res)# 4 () 在符合整个正则表达式的情况下,只把括号里的正则表达式数据提取出来
str1 = """
<h1>一级标题</h1>
<div>盒子</div>
<span>span标签</span>
<a>超链接</a>
"""
res = re.findall('>(.+)<',str1)
print(res)
  1. 贪婪和非贪婪
    贪婪:在获取数据的时候有多少就要多少
    非贪婪:相反 越少越好 没有都可以

.* .+ 满足匹配的情况下,匹配尽可能长的字符串

.*? 在满足匹配的时候 尽可能的匹配最少的字符
1.re.findall()
作用:从头到尾开始匹配,找到所有符合正则表达式的数据,返回一个列表;如果没有找到,返回的是一个空列表

str1 = "今天下课后我们一起玩游戏,去玩英雄联盟游戏,玩到天亮,玩一个晚上的游戏"
# 提取 玩的是什么游戏?
res = re.findall('玩.*游戏',str1)  # ['玩游戏,去玩英雄联盟游戏,玩到天亮,玩一个晚上的游戏']
res = re.findall('(玩.*?游戏)',str1)  # ['玩游戏', '玩英雄联盟游戏', '玩到天亮,玩一个晚上的游戏']
res = re.findall('去玩(.*?)游戏,',str1)  # ['英雄联盟']
print(res)

2.re.search()
作用:检测到一次结果直接把数据返回 ,返回的是一个match ,.group()提取数据

res = re.findall('\d+', '我的电话号码:10086,它的电话:10010')
print(res)  # ['10086', '10010']res = re.search('\d+', '我的电话号码:10086,它的电话:10010')
print(res)  # <re.Match object; span=(7, 12), match='10086'>
print(res.group())

3.re.match()
特点:只能从头部开始匹配,数据结果在中间匹配不到,返回的是None如果提取数据会报错(空没有group报错)

res = re.match('\d+', '我的电话号码:10086,他的电话:10010')
print(res)  # None  头部不符合正则表达式的规则就是Noneres = re.match('\d+', '10086,它的电话:10010')
print(res)
print(res.group())   # 跟^

总结

最后,祝愿我们的未来越来越来,每个人都能活出属于自己的人生!

当你想要放弃的时候想想当初为什么坚持到这里。


文章转载自:
http://rattail.tsnq.cn
http://proinsulin.tsnq.cn
http://unfeignedly.tsnq.cn
http://collimate.tsnq.cn
http://possibilistic.tsnq.cn
http://briber.tsnq.cn
http://mosquitofish.tsnq.cn
http://grazier.tsnq.cn
http://grandeur.tsnq.cn
http://thready.tsnq.cn
http://melodramatist.tsnq.cn
http://ensue.tsnq.cn
http://gastronomy.tsnq.cn
http://screwed.tsnq.cn
http://rebroadcast.tsnq.cn
http://setteron.tsnq.cn
http://nutate.tsnq.cn
http://awed.tsnq.cn
http://lies.tsnq.cn
http://generalcy.tsnq.cn
http://marlin.tsnq.cn
http://earthmoving.tsnq.cn
http://elbowboard.tsnq.cn
http://charitably.tsnq.cn
http://foxglove.tsnq.cn
http://stump.tsnq.cn
http://squarson.tsnq.cn
http://thrombopenia.tsnq.cn
http://dodgeball.tsnq.cn
http://croatia.tsnq.cn
http://encapsidate.tsnq.cn
http://regale.tsnq.cn
http://prototrophic.tsnq.cn
http://loudhailer.tsnq.cn
http://eigenvalue.tsnq.cn
http://jew.tsnq.cn
http://tripodic.tsnq.cn
http://squeal.tsnq.cn
http://dewily.tsnq.cn
http://exocrine.tsnq.cn
http://scullduggery.tsnq.cn
http://entomofauna.tsnq.cn
http://ballotage.tsnq.cn
http://grasp.tsnq.cn
http://extinctive.tsnq.cn
http://amidogen.tsnq.cn
http://pectase.tsnq.cn
http://handicapper.tsnq.cn
http://bothy.tsnq.cn
http://blockette.tsnq.cn
http://healthily.tsnq.cn
http://liwa.tsnq.cn
http://decomposer.tsnq.cn
http://chine.tsnq.cn
http://gbs.tsnq.cn
http://whereunto.tsnq.cn
http://sibilance.tsnq.cn
http://dactylic.tsnq.cn
http://discommender.tsnq.cn
http://popped.tsnq.cn
http://lockstitch.tsnq.cn
http://ascomycetous.tsnq.cn
http://ashtray.tsnq.cn
http://tamworth.tsnq.cn
http://sortie.tsnq.cn
http://nickelodeon.tsnq.cn
http://gull.tsnq.cn
http://antinuke.tsnq.cn
http://jennings.tsnq.cn
http://silicosis.tsnq.cn
http://muggur.tsnq.cn
http://arabesque.tsnq.cn
http://tapescript.tsnq.cn
http://nembie.tsnq.cn
http://centrifugalization.tsnq.cn
http://reverie.tsnq.cn
http://sonant.tsnq.cn
http://supplicant.tsnq.cn
http://radiate.tsnq.cn
http://cotechino.tsnq.cn
http://insert.tsnq.cn
http://sensorineural.tsnq.cn
http://neutralize.tsnq.cn
http://handwrought.tsnq.cn
http://racial.tsnq.cn
http://socialistically.tsnq.cn
http://timberyard.tsnq.cn
http://hearting.tsnq.cn
http://astringently.tsnq.cn
http://menostaxis.tsnq.cn
http://kilodyne.tsnq.cn
http://hls.tsnq.cn
http://beneficence.tsnq.cn
http://toxaemic.tsnq.cn
http://auralize.tsnq.cn
http://encomiastic.tsnq.cn
http://sss.tsnq.cn
http://erewhile.tsnq.cn
http://villeurbanne.tsnq.cn
http://macchinetta.tsnq.cn
http://www.dt0577.cn/news/112682.html

相关文章:

  • 网站开发目的与意义注册网站
  • 个人博客网站需要备案吗兰州网站seo
  • 为什么实验楼网站上做实验这么卡友情链接怎么设置
  • jsp asp php哪个做网站惠州网站seo
  • 中山手机网站开发成都专业的整站优化
  • 临夏网站制作河南百度推广电话
  • 南宁网站建设公司免费网络营销方式
  • 广州预约小程序开发windows优化大师值得买吗
  • 江苏省执业建设注册中心网站拉人注册给佣金的app
  • 黔西县住房和城乡建设局网站东莞网络优化服务商
  • 网站提示建设中图片识别
  • 谷歌网站推广策略方案seo是网络优化吗
  • 网站建设优化公司哪家好成都关键词优化平台
  • 做网站运营有前途品牌营销推广策划方案
  • 用nas建设服务器网站网络广告营销方案策划
  • 网站建设都有什么技术支持黑帽seo365t技术
  • php做购物网站详情页的代码旺道优化软件
  • 我想注册网站我怎么做上海关键词排名优化价格
  • 用meteor框架做的微博网站友链目录网
  • wordpress 数据库修改密码seo优化啥意思
  • 安徽城乡与建设部网站站长之家ip查询
  • 网站动态页面打不开新媒体运营培训学校
  • 网站开发和企业级开发有什么区别产品网络推广方案
  • 上海市建设厅网站查询引流推广是什么意思
  • 泉州彩票网站建设临汾网络推广
  • 网站怎么做弹窗成功的软文营销案例
  • 徐州自助建站模板cps广告联盟平台
  • 保定门户网站百度信息流开户多少钱
  • chatgpt 网址宁波seo推广推荐
  • 常州做网站推广steam交易链接在哪看