regex help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #1

    regex help

    trying to get this youtube regex to work with /v/videoid as well as regular youtube links.

    (http:\/\/)?(www\.)?(youtube\.com)?(\/)?(watch\?)?(v=)?([a-zA-Z0-9]{11})

    here is the current regex suggested by borked.
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.
  • iwiiiiiiiiii
    Outside The Box Geek
    • Oct 2004
    • 550

    #2
    You're regex seem ok, but I don't understand "to work with /v/videoid"
    The second time the dog bites you, it's not his fault.

    Comment

    • Kiopa_Matt
      Confirmed User
      • Oct 2007
      • 1448

      #3
      I don't understand what you're trying to do. Just get the video ID? Assuming it's PHP:

      Code:
      if (preg_match("/\?([\w\d]+)/", $url, $match)) { 
          $video_id = $match[1];
      } else { echo "No Video ID"; }
      You don't need that combumbulated mess of a regex.
      xMarkPro -- Ultimate Blog Network Management
      Streamline your marketing operations. Centralize management of domains, pages, Wordpress blogs, sponsors, link codes, media items, sales and traffic statistics, plus more!

      Comment

      • margarita
        Confirmed User
        • Jun 2003
        • 917

        #4
        all this (http:\/\/)?(www\.)?(youtube\.com)?(\/)?(watch\?)?(v=)? is useless, because you've made it optional using the "?"
        Check out my favourite kinky sponsor and must-have tool Nifty Stats

        Comment

        • u-Bob
          there's no $$$ in porn
          • Jul 2005
          • 33063

          #5
          do you need all those parts or only the video id?

          Comment

          • u-Bob
            there's no $$$ in porn
            • Jul 2005
            • 33063

            #6
            /http:\/\/?(www\.)youtube\.com\/(watch\?v=)|(\/v\/)?([a-zA-Z0-9]{11})/

            can clean it up a lot if you want

            Comment

            • 2012
              So Fucking What
              • Jul 2006
              • 17189

              #7
              the servers are humming
              best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

              Comment

              • fris
                Too lazy to set a custom title
                • Aug 2002
                • 55679

                #8
                im trying to get the video id from these types

                http://www.youtube.com/v/dgCrY8Mezd4

                http://www.youtube.com/watch?v=dgCrY8Mezd4

                http://www.youtube.com/watch?v=dgCrY...ure=grec_index

                also

                embed codes

                Code:
                <object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/xVvRfMZ-3s4?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/xVvRfMZ-3s4?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                Comment

                • iwiiiiiiiiii
                  Outside The Box Geek
                  • Oct 2004
                  • 550

                  #9
                  What u-bob gave you should work.
                  The second time the dog bites you, it's not his fault.

                  Comment

                  Working...