regex - Remove All characters between to Tags in PHP -
I am trying to find a tag and remove the whole tag with a letter inside of a PHP file Want to This is a part of the text file that I want to change or delete it:
// Some content between the code START // tag // code END // I have written this code:
$ file = file_get_contents ('file.text'); $ File = preg_replace ("# // CODE START // (. ++) // CODE END // is", "," $$ "); File_put_contents ('new.text', $ file); The problem is that the code is not working! With this one I can delete the first row:
But how can I remove those 3 lines? // CODE END // starts with // code START // .
Thanks
Update: I found it:
$ file = preg_replace ("/ \ / \ / start the code \" ( /. +?) \ / \ / CODE END \ / \ // ims ", '', $ file);
Spot the difference:
// INSTALL END // ^^ --- two L's [..snip ..] "# // START // (INSTAL END // "", '', is a $ $ file); --- Single L
Oh great , And a ninja edit completely exits from the water ...
Comments
Post a Comment