View Single Post
Old 06-28-2011, 01:41 PM  
The Dawg
Confirmed User
 
The Dawg's Avatar
 
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
Help REGEX help with Vbulletin cleaner.php

I need to replace all of the mod code from an outdated youtube video embedding mod [ame] to [video].

Old code:

Code:
[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - ‪Bill O'Reilly Interviews Rapper Lupe Fiasco - 06/20/11‬‏[/ame]
I want the new code to look like this:

Code:
[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]
Cleaner.php has this section to do the search and replace:

Code:
// BACK UP YOUR DATABASE
$replacer = array(
                        ""      => "",
                        ""      => "",
                        ""      => "",
);
I want to add a $text = preg_replace with regex code to replace the old code.

I got this from stackoverflow:

Quote:
$text = preg_replace('#\[ame\=".*?\=([a-zA-Z0-9]*?)"]#', '([video=youtube;$1]https://youtube.com/watch?v=$1[/video])', $text);
and

Code:
$text = preg_replace('|\[ame="https://youtube.com/watch\?v=([a-z0-9]+)"\]|i', '[video=youtube;$1]https://youtube.com/watch?v=$1[/video]', $text);
The code looks right, but neither affected the thread text.

Anyone know how to make this work?

The Dawg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote