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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/153070-preg_replace/#findComment-803975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.