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

  • Home
  • SEARCH
  • 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 6069469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:49:33+00:00 2026-05-23T09:49:33+00:00

This is a bit hard to sum up in a title, but here is

  • 0

This is a bit hard to sum up in a title, but here is my problem:

(?:(?:http|https):\\/\\/)?(?:\\/\\/www\\.)?youtube.com\\/watch\\?(?:.*)v=(\\w{11}).*

Given the expression given below, I really really don’t understand why ftp://www.youtube.com/watch?v=F5eScJmYZZ8 matches. I unsuccessfully tried to add ^ to the expression beginning, but then, my expression does not match anything anymore (this is done in Java, that explains the doubled backslashes).

How can ftp be accepted as it is clearly not listed in (http|ftp)?

EDIT

To be accurate, here is what is allowed:

  • http(s)://www.[…]
  • http(s)://[…]
  • http://www.[…%5D
  • […]

and nothing else.

  • 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-23T09:49:33+00:00Added an answer on May 23, 2026 at 9:49 am

    Because the leading (?:(?:http|https):\\/\\/)? is optional. That’s what the question mark at the end of the group signifies (match at most one, i.e. match only if it exists).

    A leading ^ should prevent the match with ftp though. Can you post the failing regex you tried (with the ^)?

    UPDATE:

    Aha! It matches without the ^ since the http group is optional, and anything can come before the match (e.g. cheeseyoutube.com/... would match). Adding a ^ to the beginning of the regex fixes this, but there’s another problem with your regex: the www group is trying to match two slashes (as first pointed out in Justin’s answer), which it can’t once the http group has already matched those slashes. So the www group fails to match (fine, since it’s optional), but then the youtube part can’t match since there’s an unmatched www in the way!

    This should fix your problem:

    ^(?:(?:http|https):\\/\\/)?(?:www\\.)?youtube.com\\/watch\\?(?:.*)v=(\\w{11}).*
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's a bit hard to explain, but if you go here: http://ewsprojects.com/~lyons , click
This is a bit hard for me to articulate, but in PHP you can
Sorry, the title is a bit hard to understand but I'm not 100% sure
This is a bit hard to explain, but I seem to be occasionally unable
It's a little bit hard to find an appropriate title for this. I think
It's a bit hard to word this but I have found that some websites
Okay, this will be a bit hard to explain, but I'll try my best.
This is something that I always find a bit hard to explain to others:
its a little bit hard to understand. in the header.php i have this code:
It's a bit hard to search for it. This might actually be a Rails

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.