首页 > 解决方案 > 为什么我的正则表达式找不到所有结果?

问题描述

我正在尝试缩小字符串并找到所有路径。

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.']

如何更改正则表达式以便它只找到路径而不是中间文本?

标签: pythonregex

解决方案


推荐阅读