Jump to content

Replace/remove if starts with


newbtophp

Recommended Posts

Hi,

 

Im trying to modify the following expression:

 

$str = preg_replace('~^\s*\?>~', '', $str);

 

Currently it replaces ?> if its proceeded by whitespace, however I also want it to replace the ?> if its not proceed by <?(php)? before the ?>, I've tried the following:

 

$str = preg_replace( '~^(?<!<\?)\s*\?>~', '', $str);

 

But that did'nt seem to work.

Link to comment
https://forums.phpfreaks.com/topic/209545-replaceremove-if-starts-with/
Share on other sites

  • 2 weeks later...
  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.