I will have a string (one line) composed by a HTML code that will be stored in a PHP variable. This string comes from a HTML page that normally has new line and white spaces between tags. We can have new line (one or more) and, or white space like this exemle:
<h1>tag1</h>
<p>Between h ad p we have \s and \n</p>
After perform a regex and preg_replace I would like to have this:
<h1>tag1</h><p>Between h ad p we have \s and \n</p>
I have tried this regex but it is not workig.
$str=<<<EOF
<h1>tag1</h>
<p>Between h ad p we have \s and \n</p>
EOF;
$string = trim(preg_replace('/(>\s+<)|(>\n+<)/', ' ', $str));
Here you can find the entire code http://www.phpliveregex.com/p/7Pn