![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 | |
Confirmed User
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] Code:
[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video] Code:
// BACK UP YOUR DATABASE $replacer = array( "" => "", "" => "", "" => "", ); 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? ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
|
Bump for more eyes.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,359
|
why not just create a new custom bb code, or are you trying to replace all the current ones via the database?
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Damn Right I Kiss Ass!
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,406
|
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:
<? $text = '[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - ‪Bill O\'Reilly Interviews Rapper Lupe Fiasco - 06/20/11‬‏[/ame]'; $text3 = preg_replace('|\[ame="https://youtube.com/watch\?v=([a-z0-9]+)"\](.+)|i', '[video=youtube;$1]https://youtube.com/watch?v=$1[/video]', $text); echo "$text <br><br>$text3"; $text5 = '[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]'; echo "<br><br>$text5"; ?> [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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Damn Right I Kiss Ass!
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,406
|
Of course you could just run this on the DB as Fris suggested and be done with it.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | ||
Confirmed User
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
|
Quote:
Quote:
![]() |
||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Damn Right I Kiss Ass!
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,406
|
this won't make changes to the DB... so far as I know... didn't see what you were using to do that.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 | |
Confirmed User
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
|
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); |
|
![]() |
![]() ![]() ![]() ![]() ![]() |