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
https://forums.phpfreaks.com/topic/67483-php-combining-regex/
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
https://forums.phpfreaks.com/topic/67483-php-combining-regex/#findComment-338829
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.