I am trying to grab contents/tags inside form tag using preg_match_all, here is the regular expression
/<form\b[^>]*>(.*?)<\/form>/i
But i wonder, why it doesn't work! Any idea?
I am trying to grab contents/tags inside form tag using preg_match_all, here is the regular expression
/<form\b[^>]*>(.*?)<\/form>/i
But i wonder, why it doesn't work! Any idea?
By default, the .
(DOT) does not match line breaks. If you enable DOT-ALL with the s
modifier, it does match those chars:
/<form\b[^>]*>(.*?)<\/form>/is
Realize that you won't be able to match something like:
<form>
...
<!-- </form> -->
...
</form>
to name just one of the possibilities.
Don't use regular expressions to parse HTML. Use an HTML parser.