Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Luan Patric

[Resolvido] Converter "ereg_replace" para "preg_match

Recommended Posts

Galera é o seguinte tenho um script de mural de recados do meu site que funcionava normalmente, porem com a nova versao do php apareceram uns erros, ja fiz a mudança necessaria no script, só que depois que eu fiz a mudança esta aparecendo essa menssagem:

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier '/' in

 

abaixo a parte do codigo que eu alterei

 

############### bbcode ##########################
function bbcode($text) {

 $text=preg_replace("/\\[img\\](http://[^\\[]+)\\[/img\\]/","<img src=\"\\1\" border=\"0\">",$text);
 $text=preg_replace("/\\[b\\]([^\\[]*)\\[/b\\]/","<b>\\1</b>",$text);
 $text=preg_replace("/\\[i\\]([^\\[]*)\\[/i\\]/","<i>\\1</i>",$text);
 $text=preg_replace("/\\[u\\]([^\\[]*)\\[/u\\]/","<u>\\1</u>",$text);
 $text=preg_replace("/\\[email\\]([^\\[]*)\\[/email\\]/","<a href=\"mailto:\\1\">\\1</a>",$text);
 $text=preg_replace("/\\[url\\]www.([^\\[]*)\\[/url\\]/","<a href=\"http://www.\\1\" target=\"_blank\">www.\\1</a>",$text);
 $text=preg_replace("/\\[url\\]([^\\[]*)\\[/url\\]/","<a href=\"\\1\" target=\"_blank\">\\1</a>",$text);
 $text=preg_replace("/\\[url=www.([^\\[]+)\\]([^\\[]*)\\[/url\\]/","<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",$text);
 $text=preg_replace("/\\[url=http://([^\\[]+)\\]([^\\[]*)\\[/url\\]/","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$text);  
 $text=preg_replace("/\\[i\\]([^\\[]*)\\[/i\\]/","<i>\\1</i>",$text);
 $text=preg_replace("/\\[u\\]([^\\[]*)\\[/u\\]/","<u>\\1</u>",$text);
 $text=preg_replace("/\\[b\\]([^\\[]*)\\[/b\\]/","<b>\\1</b>",$text);
 return $text;
}

 

se alguem poder me ajudar eu agradeço, Valeuu!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

uma ER geralmente fica entre barras

//

Compartilhar este post


Link para o post
Compartilhar em outros sites

toda esta parte indica este erro

 

 

$text=preg_replace("/\\[img\\](http://[^\\[]+)\\[/img\\]/","<img src=\"\\1\" border=\"0\">",$text);
 $text=preg_replace("/\\[b\\]([^\\[]*)\\[/b\\]/","<b>\\1</b>",$text);
 $text=preg_replace("/\\[i\\]([^\\[]*)\\[/i\\]/","<i>\\1</i>",$text);
 $text=preg_replace("/\\[u\\]([^\\[]*)\\[/u\\]/","<u>\\1</u>",$text);
 $text=preg_replace("/\\[email\\]([^\\[]*)\\[/email\\]/","<a href=\"mailto:\\1\">\\1</a>",$text);
 $text=preg_replace("/\\[url\\]www.([^\\[]*)\\[/url\\]/","<a href=\"http://www.\\1\" target=\"_blank\">www.\\1</a>",$text);
 $text=preg_replace("/\\[url\\]([^\\[]*)\\[/url\\]/","<a href=\"\\1\" target=\"_blank\">\\1</a>",$text);
 $text=preg_replace("/\\[url=www.([^\\[]+)\\]([^\\[]*)\\[/url\\]/","<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",$text);
 $text=preg_replace("/\\[url=http://([^\\[]+)\\]([^\\[]*)\\[/url\\]/","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$text);  
 $text=preg_replace("/\\[i\\]([^\\[]*)\\[/i\\]/","<i>\\1</i>",$text);
 $text=preg_replace("/\\[u\\]([^\\[]*)\\[/u\\]/","<u>\\1</u>",$text);
 $text=preg_replace("/\\[b\\]([^\\[]*)\\[/b\\]/","<b>\\1</b>",$text);
 return $text;

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'b' in /home/public_html/mural/includes/functions.gb.php on line 104

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier '\' in /home/public_html/mural/includes/functions.gb.php on line 105

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier '\' in /home/public_html/mural/includes/functions.gb.php on line 106

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'a' in /home/public_html/mural/includes/functions.gb.php on line 107

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'r' in /home/public_html/mural/includes/functions.gb.php on line 108

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'r' in /home/public_html/mural/includes/functions.gb.php on line 109

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'r' in /home/malhadao/public_html/mural/includes/functions.gb.php on line 110

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier '/' in /home/public_html/mural/includes/functions.gb.php on line 111

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier '\' in /home/malhadao/public_html/mural/includes/functions.gb.php on line 112

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier '\' in /home/public_html/mural/includes/functions.gb.php on line 113

 

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'b' in /home/public_html/mural/includes/functions.gb.php on line 114

Compartilhar este post


Link para o post
Compartilhar em outros sites

Certo .. faz assim então:

function bbcode($text) {

 $text=preg_replace("!\\[img\\](http://[^\\[]+)\\[/img\\]!","<img src=\"\\1\" border=\"0\">",$text);
 $text=preg_replace("!\\[b\\]([^\\[]*)\\[/b\\]!","<b>\\1</b>",$text);
 $text=preg_replace("!\\[i\\]([^\\[]*)\\[/i\\]!","<i>\\1</i>",$text);
 $text=preg_replace("!\\[u\\]([^\\[]*)\\[/u\\]!","<u>\\1</u>",$text);
 $text=preg_replace("!\\[email\\]([^\\[]*)\\[/email\\]!","<a href=\"mailto:\\1\">\\1</a>",$text);
 $text=preg_replace("!\\[url\\]www.([^\\[]*)\\[/url\\]!","<a href=\"http://www.\\1\" target=\"_blank\">www.\\1</a>",$text);
 $text=preg_replace("!\\[url\\]([^\\[]*)\\[/url\\]!","<a href=\"\\1\" target=\"_blank\">\\1</a>",$text);
 $text=preg_replace("!\\[url=www.([^\\[]+)\\]([^\\[]*)\\[/url\\]!","<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",$text);
 $text=preg_replace("!\\[url=http://([^\\[]+)\\]([^\\[]*)\\[/url\\]!","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$text);  
 $text=preg_replace("!\\[i\\]([^\\[]*)\\[/i\\]!","<i>\\1</i>",$text);
 $text=preg_replace("!\\[u\\]([^\\[]*)\\[/u\\]!","<u>\\1</u>",$text);
 $text=preg_replace("!\\[b\\]([^\\[]*)\\[/b\\]!","<b>\\1</b>",$text);
 return $text;
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Certo .. faz assim então:

function bbcode($text) {

 $text=preg_replace("!\\[img\\](http://[^\\[]+)\\[/img\\]!","<img src=\"\\1\" border=\"0\">",$text);
 $text=preg_replace("!\\[b\\]([^\\[]*)\\[/b\\]!","<b>\\1</b>",$text);
 $text=preg_replace("!\\[i\\]([^\\[]*)\\[/i\\]!","<i>\\1</i>",$text);
 $text=preg_replace("!\\[u\\]([^\\[]*)\\[/u\\]!","<u>\\1</u>",$text);
 $text=preg_replace("!\\[email\\]([^\\[]*)\\[/email\\]!","<a href=\"mailto:\\1\">\\1</a>",$text);
 $text=preg_replace("!\\[url\\]www.([^\\[]*)\\[/url\\]!","<a href=\"http://www.\\1\" target=\"_blank\">www.\\1</a>",$text);
 $text=preg_replace("!\\[url\\]([^\\[]*)\\[/url\\]!","<a href=\"\\1\" target=\"_blank\">\\1</a>",$text);
 $text=preg_replace("!\\[url=www.([^\\[]+)\\]([^\\[]*)\\[/url\\]!","<a href=\"http://www.\\1\" target=\"_blank\">\\2</a>",$text);
 $text=preg_replace("!\\[url=http://([^\\[]+)\\]([^\\[]*)\\[/url\\]!","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$text);  
 $text=preg_replace("!\\[i\\]([^\\[]*)\\[/i\\]!","<i>\\1</i>",$text);
 $text=preg_replace("!\\[u\\]([^\\[]*)\\[/u\\]!","<u>\\1</u>",$text);
 $text=preg_replace("!\\[b\\]([^\\[]*)\\[/b\\]!","<b>\\1</b>",$text);
 return $text;
}

 

 

vlw, funcionou muito bem!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.