I am trying to write a regex in python to parse a file having contents like this :-
static const PropertyID PROPERTY_X = 10225;
//static const PropertyID PROPERTY_Y = 10226;
//static const PropertyID PROPERTY_Z = 10227;
I want to extract the property name and number for only non commented properties.
This is the expression I wrote
tuples = re.findall(r"[^/]*static[ \t]*const[ \t]*PropertyID[ \t]*(\w+)[ \t]*=[ \t]*(\d+).*",fileContents)
where fileContents has the data of file as string.
But this regex is even matching the commented(lines with //) lines.
How to make it avoid matching the commented lines.
You could specify that, after the start of the line, you only want spaces before the first
static: