python - 为什么我的正则表达式找不到所有结果?
问题描述
我正在尝试缩小字符串并找到所有路径。
pathRegex = re.compile(r"^([cC]?[:]?\\)([\a-zA-Z0-9]*)$\S")
mo = pathRegex.findall(r"I have two paths. First is C:\Users\patrick
and the other is C:\Users\patrick\documents.")
但我不断得到的输出是:
['C:\\Users\\pgrimm and the other is C:\\Users\\pgrimm\\documents.']
如何更改正则表达式以便它只找到路径而不是中间文本?
解决方案
推荐阅读
- javascript - 为什么我的 Observable 从未解决?
- jquery - 对文件名的 jquery 更改在 firefox 和 chrome 上的行为不同
- loops - Userform - Catia VBA - 循环遍历文本框
- php - PHP Mobile Camera Upload Not Working
- django - Django Restful API 设计验证逻辑
- javascript - 找不到在 docker 环境中运行的节点 js 应用程序的模块错误
- mysql - 如果忘记分号,则更新 Postgres psql 提示
- rcpp - 如何检查列表是否递归地包含列表
- python - Pyspark在第二个数据框中加入多行数据框
- javascript - 如何在反应中创建更多状态?反应状态的属性数量是固定的吗?