博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python开发笔记之正则表达式的使用
阅读量:6869 次
发布时间:2019-06-26

本文共 405 字,大约阅读时间需要 1 分钟。

  1. 查找正则表达式

    import rere_txt = re.compile(r'(\d)*.txt')m = re_txt.search(src)if not m == None:    m.group(0) #complete str    m.group(1) # first group string
  2. 匹配正则表达式

    if re.match(r'(\d)*.txt',path):    print("match")else:    print("not match")
  3. 分割正则表达式

    list = re.split(r'\d',string)
  4. 替换正则表达式

    re.sub(r'\d*',rep,src)

参考

转载于:https://www.cnblogs.com/peaceWang/p/Python-kai-fa-bi-ji-zhi-zheng-ze-biao-da-shi-de-sh.html

你可能感兴趣的文章
英语文章、常用短语部分摘选集锦
查看>>
ADMT3.2域迁移之Server2003至Server2012系列(七)安装ADMT3.2
查看>>
DISPLAY环境变量的作用
查看>>
006.递归和分治思想
查看>>
org.springframework.data.mapping.PropertyReferenceException: No property xxxx found for type Xxxx
查看>>
Gson解析json数据 亲自测试可用
查看>>
我与监控宝之间的点点滴滴
查看>>
delphi 数据库显示的TDBGrid配置
查看>>
对51CTO的看法
查看>>
userenv和sys_context函数
查看>>
是否会回到起点.回忆只能是回忆
查看>>
原创数据结构算法Flash动画演示课件-Action Script(AS)脚本实现
查看>>
基于Mysql主从同步的读写分离
查看>>
BA 的岗位要求3
查看>>
基于Hyper-V3.0搭建XenDesktop7之九 部署虚拟应用之模板准备
查看>>
JS如何捆绑TypeScript声明文件
查看>>
samba服务配置
查看>>
我的友情链接
查看>>
MyBatis之ResultMap标签
查看>>
[转]WinXP、Win7脚本自动加域及用户资料迁移
查看>>