The Little Guy Posted July 16, 2012 Share Posted July 16, 2012 is there a way to replace all <? with <?php and leave all <?php alone? I am using javascript, but it is still regexp, so I thought I would post in the regexp section. I came up with this: code = code.replace(/\<\?[^php]/g, "<?php\n"); but it removes the first letter after php the beginning of the string: <?namespace becomes: <?php amespace as you can see the "n" is missing... Link to comment https://forums.phpfreaks.com/topic/265765-match/ Share on other sites More sharing options...
JAY6390 Posted July 16, 2012 Share Posted July 16, 2012 $result = preg_replace('/<\?(?!php)/', '<?php', $subject); Link to comment https://forums.phpfreaks.com/topic/265765-match/#findComment-1361920 Share on other sites More sharing options...
The Little Guy Posted July 16, 2012 Author Share Posted July 16, 2012 Thanks! That seems to work! Link to comment https://forums.phpfreaks.com/topic/265765-match/#findComment-1361922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.