Hi there,
I'm writing a python script to loop through a directory of CSS files and save the contents of any which contain a specifically-formatted javadoc style comment.
The comment/CSS looks like this:
/**thirdpartycss
* @description Used for fixing stuff
*/
.class_one {
margin: 10px;
}
#id_two {
padding: 2px;
}
The regex to fetch the entire contents of the file looks like this:
pattern = "/\*\*thirdpartycss(.*?)}$"
matches = re.findall(pattern, css, flags=re.MULTILINE | re.DOTALL)
This gives me the file contents. What I want to do now is write a regex to grab each CSS definition within the class. This is what I tried:
rule_pattern = "(.*){(.*)}?"
rules = re.findall(rule_pattern, matches[0], flags=re.MULTILINE | re.DOTALL)
I'm basically trying to find any text, then an opening {, any text, then a closing } - I want a list of all of the CSS classes, essentially, but this just returns the entire string in one chunk.
Can anybody point me in the right direction?
Thanks. Matt