newbtophp Posted August 2, 2010 Share Posted August 2, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/209545-replaceremove-if-starts-with/ Share on other sites More sharing options...
Adam Posted August 11, 2010 Share Posted August 11, 2010 however I also want it to replace the ?> if its not proceed by <?(php)? before the ?> .. on the same line or throughout the string? Quote Link to comment https://forums.phpfreaks.com/topic/209545-replaceremove-if-starts-with/#findComment-1098180 Share on other sites More sharing options...
newbtophp Posted August 14, 2010 Author Share Posted August 14, 2010 however I also want it to replace the ?> if its not proceed by <?(php)? before the ?> .. on the same line or throughout the string? Throughout so if theirs no <?php opening tag before it remove it. Quote Link to comment https://forums.phpfreaks.com/topic/209545-replaceremove-if-starts-with/#findComment-1099165 Share on other sites More sharing options...
fortnox007 Posted September 18, 2010 Share Posted September 18, 2010 what if you put it in ( ) like (\?>)$ Quote Link to comment https://forums.phpfreaks.com/topic/209545-replaceremove-if-starts-with/#findComment-1112341 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.