4 ms·
This unexpectedly matches: re.match('^bob$', 'bob\n') I didn't want the trailing newline to be included.
by iainmerrick 3y ago
This unexpectedly matches:
re.match('^bob$', 'bob\n')
I didn't want the trailing newline to be included.
- wodenokoto 3y agoBut that string does have a new line at the end.
- iainmerrick 3y agore.match('^bob$', 'bob') → yes re.match('^bob$', 'bobs') → no Most people would expect 'bob\n' not to match, because I used '$' and it has an extra character at the end, just like 'bobs'. In Python it does match because '\n' is a special case.
- rerdavies 3y ago... for some arbitrary definition of "most people".
- iainmerrick 3y agoThat’s true, probably fewer than ten million people in the world would have an opinion one way or the other. :)