I have a line with the code
require_once(PATH_ROOT).'/calls/inumber.php'); //this is a comment<br>
I want to delete everything with SED after the //. My first try was
sed -i 's/[//].*//' file;
But that deletes everthing after (PATH.ROOT).'/
I want to remove the comment, not the PATH. Ir is not in the sample above, but how can I exclude SED, not to delete after http:// cause there are two // too.
EDIT: Ok, the quest is, to remove all One-Line-Comments that starts with at least two slashes. It doesnt matter what letters/numbers/signs follow, replace it with nothing. The only exception is http(s):// that should be skipped. Examples and results:
$a=5; //first comment
$a=5;
$b=10; ////// second comment
$b=10;
$c=15; /// /*&/$%§$%&/& third comment
$c=15;
/////////////////////////////
should be empty string
/*test comment*/
/*test comment*/ --> no change cause there are no TWO slashes
Summary: everything after // should be removed (incl the two //) except the http(s)://
https://www.w3schools.com/php/showphp.asp?filename=demo_syntax_comments or for url:
https://www.w3schools.com/php/showphp.asp?filename=demo_filter7 – noobee Oct 28 '18 at 20:24