Jump to content

preg_replace


andyd34

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.