Reputation: 341
I'm building a syntax highlighting script and i've got some problems with my regex. I've been failing for about 2 days now so i need help.
I want to select everything that not /* */
or between them and this is what i got atm, not working tho, but seems close:
^(?!(\/\*.*\*\/)$)
An example of i want:
/* I want to select everything but these comments */
.class-1 {
font-family: 'SourceCodePro';
font-size: 16px;
line-height: 18px;
}
/* I want to select everything but these comments */
.class-2 {
background-color: rgb(40, 40, 40);
border: 1px solid rgb(20, 20, 20);
padding: 10px 15px 10px 15px;
}
I've solved the other regex selections for the rest of the code, but since it's applying to the comments also i need to first select everything but them.
Upvotes: 0
Views: 140
Reputation: 49
Take a look at this https://regex101.com/r/cN5aT1/2
/^(?!(\/\*(.+)\*\/)).*/gm
It is not working if comments are multiline
Upvotes: 1