在Python中搜索/匹配regex

2024-09-25 00:29:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在原始文本中匹配一些特殊的模式。但我发现了一些问题。你知道吗

文本包含:

Ended recipe step 2 for material 1A121097-13 at elapsed time 20.43. Step type: EndPT,-7 waferID,-11 1A121097-13,-12 resourceName,-3 PM3,-9 timeStamp,+21 03/09/14 08:20:27.10,

如果我使用模式:

r'Ended recipe step 2 for material (1A1\d[Y\d]\d{3}-\d\d) at elapsed time (\d\d+?.\d\d+?). Step type: EndPT,.{68,100}?(\d\d/\d\d).'

我能成功地得到我想要的。但是,如果我想了解更多信息并使用另一种模式:

r'Ended recipe step 2 for material (1A1\d[Y\d]\d{3}-\d\d) at elapsed time (\d\d+?.\d\d+?). Step type: EndPT,.{47,52}?(PM/d),.{17,44}?(\d\d/\d\d).'

我只能得到[]。你知道吗

为什么?你知道吗


Tags: 文本fortimetypestep模式recipeat