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