Jump to content
Sign in to follow this  
adn

Preg_replace et les expressions

Recommended Posts

Hello

Comment feriez-vous pour remplacer dans un code une chaine du type <?php include('tutu.php); ?>

J'ai essayé sans conviction ce truc ;) mais bon çà ne marche pas bien sûr.

$Texte = preg_replace('/<?.*include.*tutu\.php.*?>/smiU', '', $Texte);	

Share this post


Link to post
Share on other sites

Il faut "échapper" les caractères comme ?, ( et ) qui ont une signification particulière dans une regex, en mettant un \ devant.

"/<\?php include\('tutu\.php'\); \?>/"

Jacques.

Share this post


Link to post
Share on other sites

Super çà marche, merci :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...