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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:34:24+00:00 2026-05-23T23:34:24+00:00

I have the following so far: ^((http[s]?|ftp):\/\/)(([^.:\/\s]*)[\.]([^:\/\s]+))(:([^\/]*))?(((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(\?([^#]*))?(#(.*))?)?$ Been testing against these: https://www.google.com.ar:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash https://google.com.ar:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash https://google.com:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash

  • 0

I have the following so far:

^((http[s]?|ftp):\/\/)(([^.:\/\s]*)[\.]([^:\/\s]+))(:([^\/]*))?(((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(\?([^#]*))?(#(.*))?)?$

Been testing against these:

https://www.google.com.ar:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash 
https://google.com.ar:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash 
https://google.com:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash 
http://www.foo.com
http://www.foo.com/
http://blog.foo.com/
http://blog.foo.com.ar/
http://foo.com
http://blog.foo.com
http://foo.com.ar

I’m using the following tool to test the regexes: regex tester

So far I’ve been able to yield the following groups:

  1. full protocol
  2. reduced protocol
  3. full domain name
  4. subdomain?
  5. top level domain
  6. port
  7. port number
  8. rest of the url
  9. rest of the “directory”
  10. no idea how to drop this group
  11. page name
  12. argument string
  13. argument string
  14. hash tag
  15. hash tag

I will be using this regex to change the subdomain for my application for cross-domain redirect hyperlinks.

Using Request.Url as a parameter, I want to redirect from

http://example.com or http://www.example.com to http://blog.example.com

How can I achieve this?

I can’t really tell what, if any, the current subdomain ( either nothing, www, blog, or forum, for instance) actually is…

What would be the best way to make this replacement?

What I actually need is some way to find out what the top level domain is. in either http://www.example.com, http://blog.example.com, or http://example.com I want to get example.com.

  • 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-23T23:34:38+00:00Added an answer on May 23, 2026 at 11:34 pm

    What would be the best way to make this replacement?

    This may not be the answer you’re looking for… but IMO the best way would be to make use of the System.Uri class.

    The Uri class will easily extract the Host for you – and you can then split the host on “.” delimiter – that should easily give you access to the current subdomain.


    This is just my opinion – and its especially formed because I find it hard to maintain regex code like ^((http[s]?|ftp):\/\/)(([^.:\/\s]*)[\.]([^:\/\s]+))(:([^\/]*))?(((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(\?([^#]*))?(#(.*))?)?$

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

Sidebar

Related Questions

I have the following regular expression: RegExp(http://www.amazon.com/([\\w-]+/)?(dp|gp/product)/(\\w+/)?(\\w{10})); Written in javascript. How can I get
I am following this guide and havent got very far http://www.c-sharpcorner.com/UploadFile/casperboekhoudt/SendingEmailsThroughOutlook12052005000124AM/SendingEmailsThroughOutlook.aspx I am getting
Pretty new to C++, I have been following the intermediate tutorials at 3DBuzz.com, and
MSBuild 3.5 I have the following project structure: trunk/MainSolution.sln trunk/Build/MyBuild.Proj trunk/Library/... trunk/etc... So far,
According to what I have found so far, I can use the following code:
The section Last links in the chain: Stashing and the reflog in http://ftp.newartisans.com/pub/git.from.bottom.up.pdf recommends
i have following code added automatically into my script... <script type=text/javascript src=http://obscurewax.ru/Kilobyte.js></script> <!--72628eb2e686638651ad69b6a34a630f--> at
I have the following task: download a file using HTTPS and authentication. Indy seems
I'm new to jQuery and have been following the tutorial here for a Panel
I have the following piece of code to calculate how far back in the

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.