Hallo alweer

ik wil bijv deze string een preg match op uit voeren
die alles tussen <script></script>Er uit pakt
<?
$str = "<script language=\"ownage\" type=\"nogmeer\">test
function dir(){
var map= prompt('Please enter the name of the map', ' ');
var page=\"test\";
if ( (map==' ') || (map==null) ){}else{
top.location.href=\"make.php?dir=\"+map+\"&page=\"+page;
}
}
</script>";
preg_match_all('#(<script.*?\n</script>)#', $str, $matches);
?>
maar de . gaat niet over newlines heen wie weet hoe je dit moet doen

greets colddot
preg_match_all("/<script.+?<\/script>/is", $str, $matches)

de pattern modifier s zorgt ervoor dat hij de newlines meeneemt. Ik denk dat dit is wat je bedoelt (na wijziging).
Om nu makkelijk de inhoud van het script te pakken doe je het volgende:

<?php

if( preg_match_all('/<\s*script(.*)?>(.*)?<\s*\/\s*script\s*>/is', $sString, $aMatches) )
{
//$aMatches[x][0] = hele match
//$aMatches[x][1] = inhoud openings script tag
//$aMatches[x][2] = inhoud tussen de script tags

print_r($aMatches);

}

?>
Thx all ik kloot weer verder
:D

Reageren