Regex to match content of HTML body in PHP
matching, multiline, php, regex
Solution
You simply have to add the `s` modifier to have the dot match all characters, including new lines :
preg_match("/<body.*\/body>/s", $content, $matches);
as explained in the doc : http://nl2.php.net/manual/en/reference.pcre.pattern.modifiers.php
Problem
I need a regex in php for matching contents between tags of an element, e.g. `<body>` and `</body>` with the perl compatible `preg_match`. So far I tried with: ``` // $content is a string with html content preg_match("/<body(.|\r\n)*\/body>/", $content, $matches); print_r($matches); ``` …but the printout is an empty array.