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 9269091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:01:30+00:00 2026-06-18T15:01:30+00:00

I need to validate a known domain, like domain.com with JavaScript, but I need

  • 0

I need to validate a known domain, like domain.com with JavaScript, but I need to validate it with any subdomain or sub-subdomains and so, and with any protocol and with any folder, sub-folder, and so, I have this regular expression:

RegEx: /http:\/\/([\.|a-z]+).domain([\.|a-z]+)\//

The problem is it not gets https/ftp/ftps… and it get domain.com/domain.org…
I need to validate, something like this:

To validate: *://*.domain.com/*
Example: http://example.domain.com/subfolder2/folder24/
Example: https://subdomain.domain.com/folder/
Example: ftp://www.example.domain.com/folder2/folder/
Example: http://www.domain.com/folder/sub-folder/

I mean, any protocol, any subdomain, and any folder, and of course, all of them together too:

Example: https://example.domain.com/folder/folder/

Any idea?

  • 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-06-18T15:01:32+00:00Added an answer on June 18, 2026 at 3:01 pm

    Try this regex:

    /^(https?|ftp):\/\/[.a-z]+\.domain\.com[.a-z0-9/-]+/
    

    This will match the domains you lisited:

    http://example.domain.com/subfolder2/folder24/
    https://subdomain.domain.com/folder/
    ftp://www.example.domain.com/folder2/folder/
    http://www.domain.com/folder/sub-folder/
    

    How it works:

    # /            - Regex start,
    # ^            - Match the start of the string,
    # (https?|ftp) - followed by `https`, `http` or `ftp`,
    # :\/\/        - followed by `://`,
    # [.a-z]+      - followed by any amount of letters or periods,
    # \.           - followed by a period,
    # domain\.com  - followed by the domain name,
    # [.a-z0-9/-]+ - followed by the rest of a possible url.
    # /            - regex end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to validate a byte[] in my model as Required but whenever I
I need to validate a phone number in javascript. The requirements are: they should
I need to validate an email address which was in the format dsfdsf@.fdsf.com As
I need to validate a date string in a specific format in Javascript. The
I do have a resultset,which I need to validate only some fields and then
I have a UITextField in my app, created in IB. I need to validate
I have a php script which I need to validate several inputs with. Is
I need to validate some user input that is encoded in UTF-8. Many have
I have an object which i need to validate. This object has properties which
In my Android application I need to validate user entered data. So I have

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.