Page 1 of 1

hello . word and sybol replacement fixing

Posted: Tue Sep 29, 2009 3:55 am
by tubeofmommment
hi .. i need help :) this is in vbulletin .. but same php


postbit_display_complete

Code: Select all

$find = "_";
$replace = " ";
$this->post['message'] = str_replace($find, $replace, $this->post['message']);
How to replace '_' only between text but not between [url} and [img} bbcodes

any 1 can help ? :(

Re: hello . word and sybol replacement fixing

Posted: Tue Sep 29, 2009 6:52 am
by uyewq
Hi,
for me you should carry this post to regex title since shortest solution will be with regular expression after a search in this forum under regex title.
i saw lots of posts like your post
sorry that i am not capable of writing complex regular expressions. Bye.

Re: hello . word and sybol replacement fixing

Posted: Tue Sep 29, 2009 7:38 am
by jackpf
Look into preg_replace_callback(). You could probably do it using straight regex...but using a callback would be easier imo.

Re: hello . word and sybol replacement fixing

Posted: Tue Sep 29, 2009 11:31 am
by tubeofmommment
jackpf wrote:Look into preg_replace_callback(). You could probably do it using straight regex...but using a callback would be easier imo.
hey thanks for info .. if i could not make this work .. can u ?? for simbolic payment ? because im noob in php and coding :) so this problem is bugging me ..
i need solution fast

Re: hello . word and sybol replacement fixing

Posted: Tue Sep 29, 2009 11:44 am
by jackpf

Code: Select all

<?php
$str = 'do_not_replace [url]repl_ace[/url] [url]repl_ace[/url] [img]repl_ace[/img]';
 
$str = preg_replace_callback(
'/\[(url|img)\](.*?)\[\/(url|img)\]/is',
function($matches){return '['.$matches[1].']'.str_replace('_', ' ', $matches[2]).'[/'.$matches[3].']';},
$str
);
 
echo $str;
?>
If you don't have >= PHP 5.3, use create_function() instead of function(){} btw.

Re: hello . word and sybol replacement fixing

Posted: Tue Sep 29, 2009 11:55 am
by tubeofmommment
Unable to add cookies, header already sent.
File: /home/minimal/public_html/minimalmelodies/includes/class_postbit.php(294) : eval()'d code
Line: 147

now im getting this error


and this on top Parse error: syntax error, unexpected T_FUNCTION in /home/minimal/public_html/minimalmelodies/includes/class_postbit.php(294) : eval()'d code on line 147

Re: hello . word and sybol replacement fixing

Posted: Tue Sep 29, 2009 12:02 pm
by jackpf
jackpf wrote:If you don't have >= PHP 5.3, use create_function() instead of function(){} btw.

Re: hello . word and sybol replacement fixing

Posted: Tue Sep 29, 2009 12:13 pm
by tubeofmommment
jackpf wrote:
jackpf wrote:If you don't have >= PHP 5.3, use create_function() instead of function(){} btw.
lol :D dude dont be mad at the NOOb :D but im totaly noob and i dot understand what to change :D i did gre8 music forum i could not get him work perfectly ....

Re: hello . word and sybol replacement fixing

Posted: Wed Sep 30, 2009 7:01 am
by jackpf
http://php.net/create_function ;)

Go on, have a go yourself. You won't learn otherwise. I did pretty much write it for you. You should at least attempt this yourself.