-2

I have a file that looks like this:

#EXTM3U
#EXTINF:-1 tvg-id="A&E [Brazil]" tvg-name="A&E **" tvg-logo="http://url/2dhy3yl" group-title="FILMES & SERIES",A&E **
http://url/live/Enrico/321/6660.ts
#EXTINF:-1 tvg-id="A E [Brazil]" tvg-name="AeE" tvg-logo="http://url/2dhy3yl" group-title="FILMES & SERIES",AeE
http://url/live/Enrico/321/232.ts
#EXTINF:-1 tvg-id="A&E [Brazil]" tvg-name="BR: AeE *" tvg-logo="http://URL/2dhy3yl" group-title="FILMES & SERIES",AeE *
http://url/live/Enrico/321/5171.ts
#EXTINF:-1 tvg-id="A&E HD [Brazil]" tvg-name="A&E HD" tvg-logo="http://URL/2dhy3yl$
http://url/live/Enrico/321/4057.ts

I want to remove everything that contains ** (double asterisk), single asteris followed by double quotes (*") and the (tvg-name="BR:) string. I managed to do it with sed but it doesnt run on php shell_exec();

Here is my sed code

sed -i '/\*\*/d' ./filename
sed -i '/tvg-name="BR:/d' ./filename
sed -i '/\*"/d' ./filename

How do i execute this with shell_exec or any other php function? Thank you!

1 Answers1

1

For PHP, assuming the contents of the file have been gathered into the $sContents parameter:

$sContents = preg_replace('/(\*\*|\*"|"BR:)/', '', $sContents);

And for sed:

sed -e 's/\*\*//' -e 's/\*"//' -e 's/"BR://' filename

sed is very old, and Perl is much more powerful, and uses the same regular expression logic as PHP:

perl -pe 's/(\*\*|\*"|"BR:)//' filename
CharlieH
  • 1,432
  • 2
  • 12
  • 19
  • Thank you, this was driving me crazy. this solved my problem. – Enrico Mendonca Dec 29 '17 at 17:41
  • 1
    @EnricoMendonca Assuming this works for you, please click on the check mark to accept this answer. And you can vote on which answer is the best by hitting the up or down arrow. – CharlieH Dec 29 '17 at 19:50