![]() |
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] Code:
[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video] Code:
// BACK UP YOUR DATABASE I got this from stackoverflow: Quote:
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); Anyone know how to make this work? :helpme |
Bump for more eyes.
|
why not just create a new custom bb code, or are you trying to replace all the current ones via the database?
|
I believe it is a problem that has more to do with where you are putting the code. I added a small piece to the code to remove the other shit at the end:
Here is the code from my example.. You can drop it into a php extension file and run it on your sever to see the output and play with it yourself... Code:
<? [ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - Bill O'Reilly Interviews Rapper Lupe Fiasco - 06/20/11[/ame] [video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video] [video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video] Which is: line 1 - original string line 2 - modified string line 3 - what you wanted. Notice 2 and 3 match. |
Of course you could just run this on the DB as Fris suggested and be done with it.
|
Quote:
Quote:
|
this won't make changes to the DB... so far as I know... didn't see what you were using to do that.
|
Quote:
I just plugged in the code: 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); |
All times are GMT -7. The time now is 07:01 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123