Possible Duplicate:
How to parse and process HTML with PHP?
I expect this one to return (bool)True or int(1)
echo var_dump(preg_match('/(<[tT][eE][xX][tT][aA][rR][eE][aA][^<>]*>)(.*?)(<\/[tT][eE][xX][tT][aA][rR][eE][aA]>)/',
"<textarea id='field-static_content' name='static_content' class='texteditor' ><p>
any content<p></textarea>"));
But I get int(0) as a result.
I try to match any string with “<textarea” (non case sensitive) followed by any other character but “<” and “>”, followed by “>”, followed by any other character, and then ended by “</textarea>” non case sensitive
Do anyone know what’s wrong with my regex pattern?
You are missing the
/sflag. Your input text contains a linebreak, which is why.*?won’t find it per default.More importantly you are missing the
/iflag for case-insensitivity. No need to write[aA][bB]…