The following regular expression
\s*([\w_]*)\s*(,\s*|=\s*(\d*)\s*,)\n
matches the following line (with appended newline)
_FIRST_ELEMENT_ = 10000,
on Windows but not on Mac. The environment I'm using it in is the Python implementation of Cinema 4D (3D Software) which uses the CPython 2.6 interpreter.
Someone was able to do a quick test for me, because I do not own a Mac. But he does not have the time to do more tests for me.
On both Platforms (Win/Mac) the same code has been tested in the Scripting Window of Cinema 4D.
import re
enum_match = re.compile('\s*(\w*)\s*(,\s*|=\s*(\d*)\s*,)\n')
line = ' _FIRST_ELEMENT_ = 10000,\n'
match = enum_match.match(line)
if not match:
print "Regex did not match."
else:
print match.groups()
Output on Windows:
('_FIRST_ELEMENT_', '= 10000,', '10000')
Output on Mac:
Regex did not match.
The only thing I can think of is that the underscore (_
) is not included in \w
on Mac.
Do you know why the regular expression matches on Windows but not on Mac?