0
$content = '<!--title:FAST-->
<iframe src="https://example.com/38d6996f11" width="600" height="400" frameborder="0" scrolling="no" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
asd
<!--nextpage--><!--title:FEM-->
<iframe src="https://example.com/38d6996f11" width="600" height="400" frameborder="0" scrolling="no" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>

<!--nextpage--><!--title:DRIVE-->
<iframe src="https://example.com/38d6996f11" width="600" height="400" frameborder="0" scrolling="no" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>

<!--nextpage--><!--title:MOLY-->
<iframe src="https://example.com/38d6996f11" width="600" height="400" frameborder="0" scrolling="no" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>

qwe';

preg_match_all('@<!--title:(.*?)-->(.*?)(?<!--nextpage)@is', $content, $content_out, PREG_PATTERN_ORDER);

echo '<pre>';
print_r($content_out);

i have problem with this preg_match_all regex, this code gives just three parts. i need them all (four part with words; not just iframes), someone can help?

  • Do you mean like this? `\R(?:\R+(\w+))?` https://regex101.com/r/Ple1oC/1 – The fourth bird Mar 21 '20 at 07:57
  • hello, thanks for it but no i am try to parse between <!title and <!-nextpage inner codes. last part doesnt have – Tamer Erdoğan Mar 21 '20 at 08:46
  • and if you try to delete iframe code at first part you can see doesn't parse well, i need exactly parse between (.*?) with part names and inner codes – Tamer Erdoğan Mar 21 '20 at 08:53
  • You are trying to match the iframes between title and nextpage? Parsing html with regex is [a hard job](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags). Perhaps it would be better to use [DOMdocument](https://www.php.net/manual/en/class.domdocument.php) instead. – The fourth bird Mar 21 '20 at 09:01
  • not just for iframes, i am just trying to parse (.*?) for inner strings or codes. iframe was just for example. the thing isnt place at last part. just we need use with indistinct like (?:) but this not work. domdocument for only html tags :( what i need example: (.*?)(?:)? – Tamer Erdoğan Mar 21 '20 at 09:11
  • You mean like this? https://regex101.com/r/JZgIRz/1 – The fourth bird Mar 21 '20 at 09:15
  • yes thanks alot. its working ! – Tamer Erdoğan Mar 21 '20 at 09:31
  • It means end of line/string. It depends on the multiline setting. See https://www.regular-expressions.info/anchors.html – The fourth bird Mar 21 '20 at 09:32

0 Answers0