I have this Regex for detecting hyphenatedBEM in CSS files
^([\.\%]?[a-z]*[-]?[a-z0-9\-]*)(\.[a-z0-9\-]*)?(__[a-z0-9]*[-]?[a-z0-9\-]*)?(--[a-z0-9]*[-]?[a-z0-9\-]*)?(\:[a-z]*)*$
but I would also like it to detect CamelCase as well...
I need to do this because we are transitioning from hyphenatedBEM to camelCase
In short, how do I write a regex that checks for
^([\.\%]?[a-z]*[-]?[a-z0-9\-]*)(\.[a-z0-9\-]*)?(__[a-z0-9]*[-]?[a-z0-9\-]*)?(--[a-z0-9]*[-]?[a-z0-9\-]*)?(\:[a-z]*)*$
or
\.[a-z][a-z0-9]*[A-Z][a-z0-9]*[A-Z][A-Z0-9]*[a-z][A-Za-z0-9]*
If neither validate then it errors/returns false
I would be validating against CSS like below and both should validate as fine...
.error__404 { ...SOME CSS CODE... } --> this is correct
.error__404--red { ...SOME CSS CODE... } --> this is correct
.userImage { ...SOME CSS CODE...} --> this is correct
.this-is-not-correct { ...SOME CSS CODE...} --> this is not correct
Any help would be greatly appreciated...