Quote:
Originally Posted by The Dawg
I need to replace an outdated mods text in posts.
Old code example:
Code:
[ame="http://www.youtube.com/watch?v=wYJ20INbM7Q"]YouTube - ‪Bill O'Reilly Interviews Rapper Lupe Fiasco - 06/20/11‬‏[/ame]
How I want the new code to look:
Code:
[video=youtube;wYJ20INbM7Q]http://www.youtube.com/watch?v=wYJ20INbM7Q[/video]
Regex I was given by a coder:
Code:
$text = preg_replace('|\[ame="http://www.youtube.com/watch\?v=([a-z0-9]+)"\](.+)|i', '[video=youtube;$1]http://www.youtube.com/watch?v=$1[/video]', $text);
I do not know where to put this in cleaner.php  
I put it here:
PHP Code:
// BACK UP YOUR DATABASE $replacer = array( $text = preg_replace('|\[ame="http://www.youtube.com/watch\?v=([a-z0-9]+)"\](.+)|i', '[video=youtube;$1]http://www.youtube.com/watch?v=$1[/video]', $text) );
// BACK UP YOUR DATABASE
and it does nothing.
Please tell me how to execute this code.
Thanks
|
You find this in cleaner.php
PHP Code:
#$text = preg_replace('##siU', '', $text);
Change it to this:
PHP Code:
$text = preg_replace('#[ame="http://www.youtube.com/watch\?v=([a-z0-9]+)"\](.+)|#siU', '[video=youtube;$1]http://www.youtube.com/watch?v=$1[/video]', $text);
Try that. Make sure you have a backup though, I couldn't test this.