计算 re.compile mask/cypher 的问题

Problems working out the re.compile mask/cypher

我有工作代码使用 re.compile 搜索给定的键并从该行中提取指定的字节。

Working cypher
S011=re.compile(r"S0\w*\W*11\b")

Searches for 'S0' at the start and '11' further in (the intervening alphanumeric changes with each file)
S012PA041       11   1001650953.34N  72627.05E 426930.97227906.7 285.3227033224 

我正在尝试对不同的输入文件使用相同的方法,但我无法计算出正确的 mask/cypher。有几行以 'P1' 开头,因此不够排他; 'P1....,V0' 是独占键。同样,键之间的数字随每个事件和文件而变化。

P1,0,01169-72-063,,1001,,1,2020:07:31:12:48:01.7,1,V01,2,,436389.57,7196330.69,,64.88354429,7.65691702,,64.88327349,7.65520631,,0.00,0.00,0.00,0.00,,248.04

我试过这些但没有成功:

V0=re.compile(r"^P1\w*\W*V0")
V0=re.compile(r"^P1\w*\W*V0\w*\W*")
V0=re.compile(r"^P1\w*V0\w*")

在比 Red Bull 上的 safe-cracker 多 运行 组合之后,我终于得到了正则表达式的正确顺序。

要使用 'P1' 识别的行,并进一步在 'V01' 中作为搜索关键字

P1,0,01169-72-063,,1001,,1,2020:07:31:12:48:01.7,1,V01,2,,436389.57,7196330.69,,64.88354429,7.65691702,,64.88327349,7.65520631,,0.00,0.00,0.00,0.00,,248.04

re.compile 识别码。

 V0=re.compile(r"^P1\s*,*:*\S*V01\s*,*:*\S*\b")