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

江宁区住房与城乡建设局网站百度免费推广有哪些方式

江宁区住房与城乡建设局网站,百度免费推广有哪些方式,营业执照上有以上除网站制作,wordpress必下载工具文章目录函数re.match函数re.search函数re.findall函数re.compile函数re.sub函数re.split函数修饰符正则表达式模式正则表达式实例函数 re.match函数 re.match()函数用于尝试从字符串的 起始位置 匹配一个模式,匹配成功返回一个匹配对象,否则返回None。…

文章目录

  • 函数
    • re.match函数
    • re.search函数
    • re.findall函数
    • re.compile函数
    • re.sub函数
    • re.split函数
  • 修饰符
  • 正则表达式模式
  • 正则表达式实例

函数

re.match函数

re.match()函数用于尝试从字符串的 起始位置 匹配一个模式,匹配成功返回一个匹配对象,否则返回None。
函数语法:re.match(pattern, string, flags=0)
实例:

import re# case_01
print(re.match(r'\d{4}-\d{2}-\d{2}', '2023-03-15'))
print(re.match(r'\d{4}-\d{2}-\d{2}', 'date:2023-03-15'))# case_02
line = "Dogs are smarter than cats"matchObj = re.match(r'(.*) are (.*?) .*', line, re.M|re.I)if matchObj:print("matchObj.group() : ", matchObj.group())print("matchObj.group(1) : ", matchObj.group(1))print("matchObj.group(2) : ", matchObj.group(2))print("matchObj.group(1,2) : ", matchObj.group(1,2))print("matchObj.groups() : ", matchObj.groups())else:print("No match!")

结果如下:
在这里插入图片描述

使用 group(num) 或 groups() 匹配对象函数来获取匹配表达式:
group(num=0): 匹配的整个表达式的字符串,group() 可以一次输入多个组号,在这种情况下它将返回一个包含那些组所对应值的元组。
groups(): 返回一个包含所有小组字符串的元组,从 1 到 所含的小组号。

re.search函数

re.search()函数用于扫描 整个字符串 并返回第一个成功的匹配,否则返回None。
函数语法: re.search(pattern, string, flags=0)
实例:

import re# case_01
print(re.search(r'\d{4}', 'abc1234'))
print(re.search(r'\d{4}', '123abc'))
print(re.search(r'\d{4}', 'abc0000d1234'))# case_02
line = "2斤黄瓜卖8.8元"pattern = r'(\d)斤(.*)卖(\d+(\.\d+)?)元'
matchObj = re.search(pattern, line, re.M|re.I)if matchObj:print(f'{matchObj.group(1)}\t{matchObj.group(2)}\t{matchObj.group(3)}')
else:print("No match!")

结果如下:
在这里插入图片描述

re.match与re.search的区别:
re.match只匹配字符串的开始,如果字符串开始不符合正则表达式,则匹配失败,函数返回None;
而re.search匹配整个字符串,直到找到一个匹配。

re.findall函数

re.findall()函数用于在字符串中找到正则表达式所匹配的所有子串,并返回一个列表,如果有多个匹配模式,则返回元组列表,如果没有找到匹配的,则返回空列表。
函数语法: findall(string[, pos[, endpos]])
实例:

import re# case_01
content = "邮箱:qa@123.com;qa@456.com"
pattern = re.compile(r"""[a-zA-Z0-9-_]+@[a-zA-Z0-9]+\.[a-zA-Z]{2,4}
""", re.VERBOSE)result1 = pattern.findall(content)
result2 = pattern.findall(content, 0, 13)
print(result1)
print(result2)# case_02
result3 = re.findall(r'(\w+)=(\d+)', 'set width=20 and height=10')
print(result3)

结果如下:
在这里插入图片描述

re.compile函数

re.compile()函数用于编译正则表达式,生成一个正则表达式( Pattern )对象。
函数语法: re.compile(pattern[, flags])
实例:

import repattern = re.compile(r'\d+')
print(pattern.match('abc123'))
print(pattern.match('abc123', 3, 5))
print(pattern.search('abc123'))
print(pattern.findall('abc123efg456'))

结果如下:
在这里插入图片描述

re.sub函数

re.sub()函数用于替换字符串中的匹配项。
函数语法: re.sub(pattern, repl, string, count=0, flags=0)
实例:

import recontent = '手机号码:13580536956'pattern = r'(1[3-9][0-9])\d{4}([0-9]{4})'print(re.sub(pattern, r'\1****\2', content))	#手机号码:135****6956

re.split函数

re.split()函数按照能够匹配的子串将字符串分割后返回列表。
函数语法: re.split(pattern, string[, maxsplit=0, flags=0])
实例:

import reprint(re.split('\W+', 'abc, 123, .!?'))
print(re.split('\W+', 'abc, 123, .!?', 1))  # 分隔1次
print(re.split('d', 'abc, 123, .!?'))   # 找不到匹配的字符串不会分割

结果如下:
在这里插入图片描述

修饰符

正则表达式可以包含一些可选标志修饰符来控制匹配的模式。修饰符被指定为一个可选的标志。多个标志可以通过按位 OR(|) 来指定。如 re.I | re.M 被设置成 I 和 M 标志。

修饰符描述
re.I使匹配对大小写不敏感
re.M多行匹配,影响 ^ 和 $
re.S使 . 匹配包括换行在内的所有字符
re.U根据Unicode字符集解析字符。这个标志影响 \w, \W, \b, \B.
re.X该标志通过给予你更灵活的格式以便你将正则表达式写得更易于理解

正则表达式模式

修饰符描述
^匹配字符串的开头
$匹配字符串的末尾。
.匹配任意字符
[…]用来表示一组字符,单独列出:[abc] 匹配 ‘a’,‘b’或’c’
[^…]不在[]中的字符:[^abc] 匹配除了a,b,c之外的字符。
re*匹配0个或多个的表达式
re+匹配1个或多个的表达式。
re?匹配0个或1个由前面的正则表达式定义的片段,非贪婪方式
re{n}精确匹配 n 个前面表达式。例如, o{2}不能匹配 “Bob” 中的 “o”,但是能匹配 “food” 中的两个o。
re{n,}匹配 n 个前面表达式。例如, o{2,} 不能匹配"Bob"中的"o",但能匹配 "foooood"中的所有 o。“o{1,}” 等价于 “o+”。“o{0,}” 则等价于 “o*”。
re{n, m}匹配n到m次由前面的正则表达式定义的片段,贪婪方式
a|b匹配a或b
(re)对正则表达式分组并记住匹配的文本
\w匹配字母数字及下划线,等价于[a-zA-Z0-9_]
\W匹配非字母数字及下划线,等价于[^a-zA-Z0-9_]
\s匹配任意空白字符,等价于 [\t\n\r\f\v]。
\S匹配任意非空字符,等价于[^\t\n\r\f\v]
\d匹配任意数字,等价于 [0-9].
\D匹配任意非数字,等价于[^0-9]
\n, \t, 等.匹配一个换行符。匹配一个制表符。等
\1…\9匹配第n个分组的内容。

正则表达式实例

实例描述
n位数字^\d{n}$
至少n位数字^\d{n,}$
m-n位数字^\d{m,n}$
由26个小写英文字母组成的字符串^[a-z]+$
Email地址^\w+([-+.]\w+)@\w+([-.]\w+).\w+([-.]\w+)*$
手机号码^(14[5|7]|(13|15|18)[0-9])\d{8}$
国内电话号码(0511-4405222、021-87888822)\d{3}-\d{8}|\d{4}-\d{7}
身份证号(15位、18位数字),最后一位是校验位,可能为数字或字符X(^\d{15}$)|(^\d{17}(\d|X|x)$)
密码(以字母开头,长度在6~18之间,只能包含字母、数字和下划线)^[a-zA-Z]\w{5,17}$
日期格式^\d{4}-\d{1,2}-\d{1,2}

文章转载自:
http://fairyland.c7625.cn
http://assimilate.c7625.cn
http://solar.c7625.cn
http://benzosulphimide.c7625.cn
http://spandrel.c7625.cn
http://saute.c7625.cn
http://dressing.c7625.cn
http://panasonic.c7625.cn
http://sickle.c7625.cn
http://perthshire.c7625.cn
http://barnacle.c7625.cn
http://sahelian.c7625.cn
http://clinometer.c7625.cn
http://crapola.c7625.cn
http://hallucinogen.c7625.cn
http://overlap.c7625.cn
http://bigger.c7625.cn
http://inlander.c7625.cn
http://gonadotrophic.c7625.cn
http://liturgic.c7625.cn
http://stenographically.c7625.cn
http://gumshoe.c7625.cn
http://neutralism.c7625.cn
http://autopsy.c7625.cn
http://semidocumentary.c7625.cn
http://atresic.c7625.cn
http://mego.c7625.cn
http://jake.c7625.cn
http://savvy.c7625.cn
http://cheekiness.c7625.cn
http://conformability.c7625.cn
http://hydrology.c7625.cn
http://mdr.c7625.cn
http://nasserist.c7625.cn
http://unfancy.c7625.cn
http://rechannel.c7625.cn
http://mussalman.c7625.cn
http://acidic.c7625.cn
http://lullaby.c7625.cn
http://fiume.c7625.cn
http://bata.c7625.cn
http://diagnostician.c7625.cn
http://iatric.c7625.cn
http://underlie.c7625.cn
http://somnambule.c7625.cn
http://mountainside.c7625.cn
http://xograph.c7625.cn
http://bookmobile.c7625.cn
http://mizrachi.c7625.cn
http://tory.c7625.cn
http://overaggressive.c7625.cn
http://fusible.c7625.cn
http://mitch.c7625.cn
http://infract.c7625.cn
http://hornito.c7625.cn
http://teporingo.c7625.cn
http://shouting.c7625.cn
http://nepalese.c7625.cn
http://smoodge.c7625.cn
http://tranylcypromine.c7625.cn
http://glacieret.c7625.cn
http://cephalothin.c7625.cn
http://pumpkin.c7625.cn
http://pleiotropism.c7625.cn
http://dowthcory.c7625.cn
http://lymphopoietic.c7625.cn
http://hydrolytic.c7625.cn
http://ferox.c7625.cn
http://misogyny.c7625.cn
http://magnetite.c7625.cn
http://chemosorb.c7625.cn
http://distributively.c7625.cn
http://cinchonidine.c7625.cn
http://illuminate.c7625.cn
http://dispiteous.c7625.cn
http://vitalistic.c7625.cn
http://catfooted.c7625.cn
http://unbearable.c7625.cn
http://varsovian.c7625.cn
http://serotype.c7625.cn
http://radionics.c7625.cn
http://truantry.c7625.cn
http://subdirectory.c7625.cn
http://americanist.c7625.cn
http://tare.c7625.cn
http://prowess.c7625.cn
http://severally.c7625.cn
http://semisolid.c7625.cn
http://philatelic.c7625.cn
http://reconcilability.c7625.cn
http://assessment.c7625.cn
http://keybutton.c7625.cn
http://doff.c7625.cn
http://folklorish.c7625.cn
http://bowshock.c7625.cn
http://allopatrically.c7625.cn
http://unicameral.c7625.cn
http://exoterical.c7625.cn
http://spur.c7625.cn
http://niceness.c7625.cn
http://www.zhongyajixie.com/news/79780.html

相关文章:

  • 企业网站建设服务商推广之家
  • 济南精品建站外包公司价格公司全网推广
  • 天河网站建设价格软文怎么写
  • 网站设计与制作合同独立站seo搜索优化
  • 官方网站的推广策划怎么做现在有哪些推广平台
  • 高考志愿网站开发宁波seo推广公司排名
  • 百度seo排名优化排行seo短视频网页入口营销
  • c2c网站方案今日新闻热点大事件
  • 创建网站目录权限北京网站优化体验
  • 制作一个静态网站源码重庆森林经典台词 凤梨罐头
  • 网站白名单 是什么百度灰色关键词排名
  • 网页制作与网站建设策划书案例微营销推广平台有哪些
  • 企业网站建设公司 丰台无锡网站优化公司
  • 刘娇娇做网站骗钱的网站建设公司
  • 蓝色大气企业网站phpcms模板网站推广的基本方法
  • 网站建设项目团队阿里域名购买网站
  • 的建站公司武汉seo公司
  • 石家庄网站建设刘华广州网络推广平台
  • 一个ip做几个网站良品铺子网络营销策划书
  • 建筑公司排名前100优化模型的推广
  • 独立网站推广公司新郑网络推广
  • wordpress能否做网站百度一下网页入口
  • 建设一个网站要钱吗seo关键字优化
  • 网站建设的目的及意义免费b站网页推广
  • vs2013 网站建设搜索引擎优化是什么
  • 电脑可以做网站服务器吗全搜网
  • 委托别人做网站 域名所有权海外网络推广
  • 注销网站备案申请表中国互联网数据平台
  • 弹性云主机做网站海外黄冈网站推广
  • 门户网站建设方案公司北京优化网站建设