You can use phpQuery. My first question here in stackflow is somehow related to your question .
$document = phpQuery::newDocumentFileHTML('[file location]');
$text = pq('div')->find('a-files')->remove()->end();
Hope it helps!
Domanda
I want to search for a certain word e.g. "a-files" for example in the href-part and in case of success, I want to remove the whole segment (in this case -> an html-tag) .
Don't delete this sentence. <a href="/a-files/X"> Click here - 1 </a> This too..
Don't delete this sentence. <a href="/a-files/Y"> Click here - 2 </a> This too..
Don't delete this sentence. <a href="/b-files/Z"> Click here - 3 </a> This too..
In the example above the following part:
<a href="/a-files/X"> Click here - 1 </a>
<a href="/a-files/Y"> Click here - 2 </a>
should be removed.
How can I do that? (PHP, Bash-Shell, Whatever..)
p.s. A possible way to do that, could be:
--> Find the word,
--> go left,
--> find "<a",
--> begin select,
--> go right,
--> find "</a>",
--> end select and
--> delete this part.
Which programming language can do that easly?
p.s. Please consider: the files are not always a html file. I have chosen an html-example, to explain it easier.
Soluzione
You can use phpQuery. My first question here in stackflow is somehow related to your question .
$document = phpQuery::newDocumentFileHTML('[file location]');
$text = pq('div')->find('a-files')->remove()->end();
Hope it helps!