Why does the following string1 regexp not match? I have tested it using this and it appears my regex-fu is accurate, so I figure I must be missing something in the python implementation:
import re
pattern = r".*W([0-9]+(\.5)?)[^\.]?.*$"
string1 = '6013-SFR6W4.5'
string2 = '6013-SFR6W4.5L'
print(re.match(pattern, string1)) # the return value is None
print(re.match(pattern, string2)) # this returns a re.match object
Here is a screenshot of an interactive session showing this issue.
EDIT
sys.version outputs 3.4.3
In the code you posted, you have:
pattern = r".*W([0-9]+(\.5)?)[^\.]?.*$"
But in the code from your screenshot, you have
pattern = r".*W([0-9]+(\.5)?)[^\.]+.*$"
(Note the ? near the end of the first pattern is replaced with a + in the second one)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With