How to select via regex all class notations in css file
By having a css file with css rules, I'd like to select only css class (i.e.)
.tblGenFixed but not css values for a rule (i.e.)
opacity: 0.3 .
This is my regex:
This is my alternative solution but it doesn't work
I have set an example in regex101 here https://regex101.com/r/gG4nN4/1
How can I ignore css rule values ?
A value will have a digit after the dot. Luckily, valid CSS class names cannot start with a digit :)
Your regexp has to match a dot first, then a letter or - or _
! if you look for whitespace before the dot, a value like .5 will match ...
Try this one :
See this too : Regex to match a CSS class name
Relevant quote :
Basically, a name must begin with an underscore (_), a hyphen (-), or a letter(a–z), followed by any number of hyphens, underscores, letters, or numbers. There is a catch: if the first character is a hyphen, the second character must be a letter or underscore, and the name must be at least 2 characters long.