andyd34 Posted April 7, 2009 Share Posted April 7, 2009 I am setting up a CMS and wnat to prevent users from showing links or email addresses. This is what I have so far $body = preg_replace( "`((http)+(s)?:(//)|(www\.))((\w|\.|\-|_)+)(/)?(\S+)?`i", "<strong>[LINK: REMOVED NOT ALLOWED]</strong>", $profile['Usr_ProfileBody']); $body = preg_replace( "`([a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+.[a-zA-Z0-9-.])?`i", "[email: REMOVED NOT ALLOWED]", $body); echo $body; The link match works fine but the email puts [email: REMOVED NOT ALLOWED] in front of every character in the $body string Does anyone have a suggestion Link to comment https://forums.phpfreaks.com/topic/153070-preg_replace/ Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 try this (untested) $body = preg_replace( "`([a-zA-Z0-9_.-]+@([a-zA-Z0-9-]+.[a-zA-Z0-9-.]+.[a-zA-Z0-9-.])?)`i", "[email: REMOVED NOT ALLOWED]", $body); OOOPs put the ( in the wrong place Link to comment https://forums.phpfreaks.com/topic/153070-preg_replace/#findComment-803975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.