Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 444835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:18:37+00:00 2026-05-12T21:18:37+00:00

I am writing temporary PHP script to update MySQL database of my vBulletin forum.

  • 0

I am writing temporary PHP script to update MySQL database of my vBulletin forum.

Here’s what it does. It finds any entry that has a [youtube][/youtube] code. And then it has to replace that code with a link to the youtube video instead.

So, here is an example of what I have to take:

$string = <<<END
Hi everyone! Check out this video that I just found on YouTube!

[youtube]<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Md1E_Rg4MGQ&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Md1E_Rg4MGQ&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>[/youtube]
END;

And I have to make that look like this instead:

[URL=http://www.youtube.com/watch/?v=Md1E_Rg4MGQ]http://www.youtube.com/watch/?v=Md1E_Rg4MGQ[/URL]

I’m getting a headache working with the Regex. I don’t have enough experience with Regex to figure out what to do.

It has to look something like this:

$string = preg_replace("#\[youtube\]?????\[/youtube\]#i", "[URL=http://www.youtube.com/watch?v=$1]http://www.youtube.com/watch?v=$1[/URL]", $string);

Help Please! ^_^

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:18:37+00:00Added an answer on May 12, 2026 at 9:18 pm

    Something like this perhaps?

    $string = preg_replace('#\[youtube\].*?name="movie" value="(.*?)".*?\[/youtube\]#i', "[URL=$1]$1[/URL]", $string);
    

    Note that this is limited in that it expects a string name="movie" value="????????????????" format precisely – technically, there are other valid HTML constructs with the same meaning but different order, etc. The ideal solution would be to use some sort of DOM parser to grab the value of the movie attribute, but if you know people will always be using that exact format (i.e. if that’s copy the copy/paste from youtube always is or the like) then regex can suffice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Without writing a custom rdbuf is there any way to use a stringstream efficiently?
I'm writing some pretty CPU-intensive, concurrent numerical code that will process large amounts of
I am interested in writing a utility that modifies PostScript files. It needs to
I'm trying to compile some software I've been writing in Linux that uses some
I'm writing an Android JUnit test and want to copy/reset a test fixture file
I am writing a GLPaint-esque drawing application for the iPad, however I have hit
(I'm using Python 2.6 and nose .) I'm writing tests for my Python app.
Hi I need to initialize an NSObject at a particular location that I specify(through
Often a web service needs to zip up several large files for download by
So I'm basically making a youtube downloader .dll. What I need is to return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.