captaingrassholm Posted October 20, 2008 Share Posted October 20, 2008 Hi, I am using the following regular expression to try and seperate php elements from plain xhtml: $arr = split("\<\?[^(?>)]+\?\>",$text); This works fine if I don't include any html closing tags in $text, otherwise not, excuse my undoubted ignorance but I thought putting ?> in brackets (escaping these makes no difference) would require a match for anything that was not a ? followed by a >, i.e. a script closing tag? Can anyone point out my no doubt obvious mistake as I have tried all sorts. Thanks, Chris Link to comment https://forums.phpfreaks.com/topic/129250-removing-php-from-webpage-source-code/ Share on other sites More sharing options...
discomatt Posted October 21, 2008 Share Posted October 21, 2008 No character classes interpret those brackets literally. So you're looking for anything that isn't an opening bracket, question mark, closing angled bracket, or closing bracket. You want to use either negative look-ahead or lazy modifiers... Lazy should get the job done faster... but it's still inefficient regex. <\?.*?\?> You'll want to execute that with the 's' flag ( dot matches newline ) Link to comment https://forums.phpfreaks.com/topic/129250-removing-php-from-webpage-source-code/#findComment-670886 Share on other sites More sharing options...
captaingrassholm Posted October 23, 2008 Author Share Posted October 23, 2008 Thanks for the advice Link to comment https://forums.phpfreaks.com/topic/129250-removing-php-from-webpage-source-code/#findComment-672638 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.