I doing conversion post contents from WordPress to own CMS. Some plugin in WP added [embed] shortcode, now I need to get content of the [embed]...[/embed] tags to change structure to embedly. Some posts have one embed tag, some more, and some have no tags.
I tried to using solutions from:
PHP/regex: How to get the string value of HTML tag?
get everything between <tag> and </tag> with php
PHP Regex find text between custom added HTML Tags
but still not working, and preg_match_all return empty arrays or arrays with wrong content, not inside embed tags.
preg_match_all('/[^embed](.*)[^\/embed]/', $content, $embeds);
example content from WP:
.....
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed faucibus nisi at lacus dignissim vehicula. Phasellus tellus lorem, mattis et porttitor non, vehicula et nisi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus a aliquet ligula. Aenean malesuada ligula urna, ut vehicula nisi dapibus a. Phasellus fringilla turpis blandit tellus scelerisque posuere. Mauris at dui nisi. Nam at viverra lectus, vel interdum velit. Nullam a risus hendrerit arcu egestas hendrerit. Morbi ut faucibus metus, eu malesuada ipsum. Integer dapibus mollis molestie. [embed]</p>
<div class="tiny-pageembed">
<iframe src="https://twitter.com/chainlink/status/xxxxxx" width="350px" height="260px" frameborder="0" scrolling="no"></iframe></div>
<p>[/embed] Ut magna sem, consectetur et aliquam vitae, mattis id tellus. Curabitur in risus sed neque condimentum congue ac sit amet ante. Cras eget rutrum justo, at pretium libero. Duis consectetur enim in nisl molestie commodo facilisis nec orci. Praesent vitae ullamcorper arcu. Phasellus aliquet, metus in pulvinar sodales, lorem eros convallis quam, nec pulvinar turpis dolor vel elit. Fusce ornare erat blandit fringilla pellentesque.</p>
.....