The following 2 lines are my code:
$rank_content = file_get_contents('https://www.championsofregnum.com/index.php?l=1&ref=gmg&sec=42&world=2');
$tmp_ = preg_replace("/.+width=.16.> /Uis", "", $rank_content, 1);
The second line above causes an infinite loop. In contrary, the following alternatives DO work:
$tmp_ = preg_replace("/.+width=.16.> /Ui", "", $rank_content, 1);
$tmp_ = preg_replace("/[^§]+width=.16.> /Uis", "", $rank_content, 1);
But sadly, they do not give me what I want - both alternatives do not include line breaks within $rank_content
.
Also, if I replaced the file_get_contents
function with something like
$rank_content = "asdfas\nasdfasdfaswidth=m16m> teststring";
There are no problems either, although \n
represents a line break, too, doesn’t it?!
So do I understand it right that RegEx has problems in noticing a String with line breaks in it?
How can I filter a substring of $rank_content
(which has multiple lines in it) by removing some lines until something like "width="16" "
appears? (Can be seen in the site's source code)