Expression régulière pour retrouver tous les tags php

ninatomb Messages postés 2 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 14 mai 2003 - 13 mai 2003 à 15:49
ninatomb Messages postés 2 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 14 mai 2003 - 14 mai 2003 à 09:28
Je recherche une expression régulière qui me retrouve tous les tags php dans une page html, sans modifier l'html
Et une qui fonctionne !!!!!
Celle ci ne fonctionne pas :
"<\?(.*)\?>"

Merci d'avance

nina

3 réponses

Magicking Messages postés 195 Date d'inscription vendredi 13 octobre 2000 Statut Membre Dernière intervention 8 juillet 2004
14 mai 2003 à 09:00
essaye
<?
$txt= "<? echo "salut"; ?>";
$pattern[0]="#\<\?(.*?)\?\>#si";
$replace[0]=" \\1 ";
$txt =preg_replace($pattern,$replace,$txt);
echo $txt;
?>
Sa devrai marchais comme ca
0
Magicking Messages postés 195 Date d'inscription vendredi 13 octobre 2000 Statut Membre Dernière intervention 8 juillet 2004
14 mai 2003 à 09:14
Mais si c'est pour rechercher c'est un preg_match_all
<?
$txt="<? echo "salut"; ?><? echo "salut"; ?><? echo "salut"; ?>";

$pattern="#\<\?(.*?)\?\>#si";
$n=preg_match_all($pattern,$txt,$nothing);
echo "Il y a $n fois <? ?>";
?>
http://www.php.net/manual/fr/function.preg-match-all.php
0
ninatomb Messages postés 2 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 14 mai 2003
14 mai 2003 à 09:28
Trop cool, ca marche !!!
un grand merci !!!

;-)))

nina
0
Rejoignez-nous