CHENLU
CHENLU

Reputation: 91

Search/Match regex in Python

I want to match some special patterns in a raw text. But I found some problems.

The text contains:

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,

If I use the pattern:

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

I can get what I want successfully. However, If I want to find out more and use another pattern:

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

I can get nothing but [].

Why?

Upvotes: 1

Views: 66

Answers (1)

falsetru
falsetru

Reputation: 368894

It's a simple typo. Replace /d with \d:

... EndPT,.{47,52}?(PM\d),.{17,44}?(\d\d/\d\d)
                      ^

Upvotes: 1

Related Questions