Jump to content

php, combining regex


phpSensei

Recommended Posts

Alright, I don't know if this is possible, but the results always come out blank for me...

 


$string = "One And Two And <b>string</b>";

$replace=array("/one/","/two/","'#<([^>]+)>(.*?)</\1>#'");
$with= array("1","2","[b]$2[/b]");

$reg=preg_replace($replace,$with,$string);

 

I want to filter bad words, and I also want to convert string to at the same time.

 

I know the regex, and I know how to change the bbcode to what I want, but I don't know if this is possible....

Link to comment
Share on other sites

SWEARING IN HERE

 

replace = array('/fuck/', '/cock/', '/shit/', '/ass/','/bitch/','/motherfucker/','/pussy/','/fucking/','/whore/'
,'/\[b\](.*?)\[\/b\]/','/\[i\](.*?)\[\/i\]/is','/\[u\](.*?)\[\/u\]/is'
);
$with = array('f***', 'c***', 's***', 'a**','b****','motherf******','p****','f***ing','wh***','<strong>$1</strong>','<em>$1</em>',  '<u>$1</u>'
);
$message=strip_tags($row['message']);
$message = preg_replace($replace, $with, $message);
$message=stripslashes($message);

 

thanks, i managed to get it working, and with your help

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.