python-re正则笔记0.2.0

1. 匹配linux文件路径

from re import match, search,findall
str="sh refreshConfig.sh /opt/client/ccc.txt  /opt/client/ccc.dfs 胜多负少的"

patter1="\/.+\.\w+"
print(findall(patter1, str))

"""
['/opt/client/ccc.txt  /opt/client/ccc.dfs']
"""

2. 匹配在linux中以sh执行的sh文件

from re import match, search,findall
str="sh cc.sh /opt/client/ccc.txt 收水电费水电费水电费径"

patter=r"sh\s.+\.sh"
result = match(patter, str)

print(result)
"""
<re.Match object; span=(0, 19), match='sh cc.sh'>
"""

参考

https://blog.csdn.net/Java_ZZZZZ/article/details/130880573

相关推荐

  1. python-re笔记0.2.0

    2024-04-12 14:32:05       45 阅读
  2. Python 表达式(re

    2024-04-12 14:32:05       12 阅读
  3. Python 表达式模块:re 模块

    2024-04-12 14:32:05       44 阅读
  4. py11-python-re

    2024-04-12 14:32:05       23 阅读
  5. Python 表达式 re . 符号

    2024-04-12 14:32:05       13 阅读
  6. Python 表达式 re.match() 和 re.search() 方法

    2024-04-12 14:32:05       12 阅读
  7. Python笔记 - 表达式

    2024-04-12 14:32:05       6 阅读
  8. 表达式RE

    2024-04-12 14:32:05       36 阅读
  9. 3.01【python表达式以及re模块】

    2024-04-12 14:32:05       40 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-12 14:32:05       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-12 14:32:05       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-12 14:32:05       20 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-12 14:32:05       20 阅读

热门阅读

  1. Bert 将长段分成句子放在一个batch输入

    2024-04-12 14:32:05       21 阅读
  2. 掌握 Awk:Linux 文本处理的终极工具

    2024-04-12 14:32:05       21 阅读
  3. 后端项目部署教程

    2024-04-12 14:32:05       16 阅读
  4. Vue 3 中,defineExpose 在<script setup> 中的使用

    2024-04-12 14:32:05       15 阅读
  5. 使用列表递推实现螺旋矩阵

    2024-04-12 14:32:05       16 阅读
  6. 如何通过子网掩码来计算IP的地址范围

    2024-04-12 14:32:05       15 阅读