Jump to content

[SOLVED] preg_replace( error


ambo

Recommended Posts

Every thing seems to line up right

Warning: preg_replace(): Compilation failed: nothing to repeat at offset 4 in /home/content/d/e/c/decuralogin/html/view_topic.php on line 164

 

<?php
$message = $rows['detail'];
$patterns = array(

"/\[url\](.*?)\[\/url\]/",
"/\[img\](.*?)\[\/img\]/",
"/\[b\](.*?)\[\/B\]/",
"/\[b\](.*?)\[\/b\]/",
"/\[u\](.*?)\[\/U\]/",
"/\[u\](.*?)\[\/u\]/",
"/\[i\](.*?)\[\/I\]/",
"/\[i\](.*?)\[\/i\]/",
"/\[quote\](.*?)\[\/quote\]/",
"/\[quote\](.*?)\[\/QUOTE\]/",
"/\[code\](.*?)\[\/code\]/",
"/\[code\](.*?)\[\/CODE\]/",
"/\[s\](.*?)\[\/s\]/",
"/\[s\](.*?)\[\/S\]/",
"/\[url=(.*?)\](.*?)\[\/url\]/",
"/\[color=(.*?)\](.*?)\[\/color\]/",
"/\[size=(.*?)\](.*?)\[\/size\]/",
"/\[marquee\](.*?)\[\/marquee\]/",
"/\[br\]/",

//emoticons

"/\:\)/",
"/\;\)/",
"/\:\(/",
"/\:O/",
"/\:P/",
"/\:\|/",
"/\:D/",
"/\:!!!\:/",
"/\:???\:/",
"/\:nin\:/",
"/\:pir\:/",
"/\:fin\:/",
"/\:roc\:/");

$replacements = array(

//bbcode

"<a href=\"\\1\">\\1</a>",
"<img border=0 src='\\1'>",
"<b>\\1</b>",
"<b>\\1</b>",
"<u>\\1</u>",
"<u>\\1</u>",
"<i>\\1</i>", 
"<i>\\1</i>", 
"<div><b>Quote:</b><div style='border:1px solid #7b950d; line-height: 16px; background:#242424; width: 99%; white-space: nowrap; overflow: auto; max-height: 25em;'>\\1</div>", 
"<div><b>Quote:</b><div style='border:1px solid #7b950d; line-height: 16px; background:#242424; width: 99%; white-space: nowrap; overflow: auto; max-height: 25em;'>\\1</div>",
"<b>Code:</b><div style='border:1px solid #7b950d; line-height: 16px; background:#242424; width: 99%; white-space: nowrap; overflow: auto; max-height: 25em;'>\\1</div>",
"<b>Code:</b><div style='border:1px solid #7b950d; line-height: 16px; background:#242424; width: 99%; white-space: nowrap; overflow: auto; max-height: 25em;'>\\1</div>",
"<s>\\1</s>",
"<s>\\1</s>",
"<a href=\"\\1\" target=\"_blank\">\\2</a>",
"<font color=\"\\1\">\\2</font>",
"<font size=\"\\1\">\\2</font>",
"<marquee>\\1</marquee>",
"<br />", 

//emoticons

"<img src=\"bbeditor/images/smilies/yellow/smile.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/wink.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/sad.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/angry.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/razz.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/umm.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/woot.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/exc.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/question.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/nin.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/pirate.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/finger.gif\" border=\"0\">",
"<img src=\"bbeditor/images/smilies/yellow/rock.gif\" border=\"0\">");


$post = preg_replace($patterns,$replacements,$message);

print $post;
?>

Link to comment
https://forums.phpfreaks.com/topic/147392-solved-preg_replace-error/
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.