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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:59:45+00:00 2026-06-07T15:59:45+00:00

I want to create a regex that parse only links that complies to the

  • 0

I want to create a regex that parse only links that complies to the current domain. I want to know if there is something like {hostname} that I can use inside a Javascript regex object so it will lock the search only to those links that are for the current page specific domain.

For example: if the domain is http://www.domain.com, it will search links only links that start with that specific domain. if the domain is anotherdomain.com, it will search only links that start with that specific domain. My regex is more complex, but I would like to be able to put some kind of global variable that will be replaced with the current domain.

  • 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-07T15:59:47+00:00Added an answer on June 7, 2026 at 3:59 pm

    You can retrieve the hostname of the current page via the Location object :

    var hostname = window.location.hostname;
    

    And then you can compose your regex using that variable by concatenating it into your regex :

    var re = new RegExp("<start of your regex>" + hostname + "<end of your regex>");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I create a regex NOT to match something? For example I want
I want to create a regex that match '.', '#' and ':' and also
Say I have a regex that checks for alphanumeric. I now want to create
I am trying to create a RegEx expression that will successfully parse the following
I want to create a regex expression that generates a match and strips off
Like the title says I am trying to create some regex that selects anything
I want to create something like smarty, but I don't want to use Smarty
I am trying to create a regex to parse document links (pdf, ppt, xls,
i want to create DateTimeAttribute like that: public class DateTimeAttribute : RegularExpressionAttribute { public
I want to create a regexp that matches exactly the string foo , even

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.