I want to write the regular expression in php matching condition below:
/*
Remove this comment line 1
Remove this comment line 2
*/
.class1
{
background:#CCC url(images/bg.png);
}
.class2
{
color: #FFF;
background:#666 url(images/bg.png); /* DON'T remove this comment */
}
/* Remove this comment */
.class3
{
margin:2px;
color:#999;
background:#FFF; /* DON'T Remove this comment */
}
...etc
...etc
Please any one give me a regular expression in php. Thanks.
If the rule is that you want to remove all comments where there is no other code on the line then something like this should work:
The ‘m’ option makes ^ and $ match the beginning and end of a line. Do you expect the comments to run for more than one line?
EDIT:
I’m pretty sure this fits the bill:
Do you understand what it’s doing?