Hi All! I would delete the heads tags's contents of a string from a request like this:
$head = "/<head>(\s.*)*<\/head>/"; $mycode = preg_replace( $head, '', $_REQUEST['mytext']); print($mycode);
The string of the request can be simplified as follows:
$mytext = '<html><head> <style type="text/css"> body { background-color:#d0e4fe; } h1 { color:orange; text-align:center; } p { font-family:"Times New Roman"; font-size:20px; } </style> <script type="text/javascript"> function mymsg() { window.alert("Benvenuto nel Tryit Editor! =D"); } </script></head><body> <h1>Tryit Editor</h1> <p>Scrivi il codice e guarda il risultato con un click! =D</p> <form> <input type="button" value="Click Me!" onClick="mymsg();" /> </form> </body></html>'
But my RegExp not work because the result of the function "preg_replace" returns a PHP error (null). So I tried to write other RegExp to try to clear the contents of the other basic tags:
$html = "/<html>(\s.*)*<\/html>/";;
$body = "/<body>(\s.*)*<\/body>/";
Inserting them in the first feature I noticed that they both work correctly. This is my problem: Why the first RegExp (head) is not working properly but the other two work? Thanks.