Vinze Posted December 23, 2006 Share Posted December 23, 2006 Hey, I want to use preg_replace() to replace all instances of <? with <?php. I can't do this with str_replace() because when I [i]do[/i] use <?php it would be converted to <?phpphp. I tried the following pattern:[code][<\?(!(php))][/code]But that doesn't work. Please help me, thanks in advance.[b]Edit:[/b] And I learned something new today: lookaheads. The correct code was:[code][<\?(?!php)][/code] Link to comment https://forums.phpfreaks.com/topic/31676-solved-pcre-find-and-replace/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.