The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Help with cleaner.php (REGEX)
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] Code:
[video=youtube;wYJ20INbM7Q]http://www.youtube.com/watch?v=wYJ20INbM7Q[/video] 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 put it here: PHP Code:
Please tell me how to execute this code. Thanks |
#2
|
||||
|
||||
What is cleaner.php? Where did you get it from?
|
#3
|
|||
|
|||
Cleaner.php is the impex/tools/ folder for Vbulletin.
|
#4
|
||||
|
||||
Quote:
You find this in cleaner.php PHP Code:
PHP Code:
Try that. Make sure you have a backup though, I couldn't test this. |
#5
|
|||
|
|||
Got some progress. :up:
(I am running this on a test database to get the syntax right) Cleaner ran but I got the error: Warning: preg_replace(): Compilation failed: unmatched parentheses at offset 48 I looked at the test thread and it deleted the string I want to replace but it did not replace it ( due to the error ) So if I can get the code correct it should work. --------------- Added [DATE]1309380139[/DATE] at [TIME]1309380139[/TIME] --------------- Success! Here is the regex pattern that worked: 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); |
#6
|
||||
|
||||
I took another look at the code, I think there were a couple typos-
try this line: 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); |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|