Is there a way to validate CSS syntax by checking for specific characters like "{", "}", ";", and ":"? I have come up with four checks to ensure the code is valid, such as verifying that the number of opening and closing curly braces match, as well as the number of colons and semicolons. Additionally, I check if it starts with a ".", ends with ";}", and includes various combinations of whitespace.
Are there other validation methods I could apply to confirm the syntax is correct?
Alternatively, does anyone have a regular expression (regex) available that can perform these checks more efficiently? I am new to regex but believe it might be able to handle the validations I mentioned above.