OM2 Posted July 30, 2008 Share Posted July 30, 2008 I have the following preg_replace code: $cleanPageCode = preg_replace("/\/\*\s*Admin Code Start\s*\*\/.*?\/\*\s*Admin Code End\s*\*\//is", "", $oldCode); In my code I have: /* Admin Code Start */ body { margin: 0; padding: 0; } /* Admin Code End */ I'm using the preg replace to get rid of the above code. Just wanted to check it was correct! (It seems to work OK... but I thought I'd ask anyway.) Thanks. OM Link to comment https://forums.phpfreaks.com/topic/117438-please-check-my-preg_replace-code/ Share on other sites More sharing options...
effigy Posted July 31, 2008 Share Posted July 31, 2008 Yes. I would make one additional modification: change the delimiters so you don't have to escape the forward slashes: %/\*\s*Admin Code Start\s*\*/.*?/\*\s*Admin Code End\s*\*/%is Link to comment https://forums.phpfreaks.com/topic/117438-please-check-my-preg_replace-code/#findComment-604546 Share on other sites More sharing options...
OM2 Posted July 31, 2008 Author Share Posted July 31, 2008 thanks for the reply. but: i still have to escape the *'s? Link to comment https://forums.phpfreaks.com/topic/117438-please-check-my-preg_replace-code/#findComment-604566 Share on other sites More sharing options...
effigy Posted July 31, 2008 Share Posted July 31, 2008 Yes, because they are metacharacters. Link to comment https://forums.phpfreaks.com/topic/117438-please-check-my-preg_replace-code/#findComment-604617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.