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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:16:03+00:00 2026-05-12T07:16:03+00:00

Given a series of URLs http://www.anydotcom.com/myfolder/some-url.html http://www.anydotcom.com/myfolder2/index.html# http://www.anydotcom.com/myfolder3/index.html?someParam=aValue http://www.anydotcom.com/foldername/index.html?someParam=anotherValue First, how could I strip

  • 0

Given a series of URLs

http://www.anydotcom.com/myfolder/some-url.html
http://www.anydotcom.com/myfolder2/index.html#
http://www.anydotcom.com/myfolder3/index.html?someParam=aValue
http://www.anydotcom.com/foldername/index.html?someParam=anotherValue

First, how could I strip anything off the end of the URL so that I end up with

http://www.anydotcom.com/myfolder/some-url.html
http://www.anydotcom.com/myfolder2/index.html
http://www.anydotcom.com/myfolder3/index.html
http://www.anydotcom.com/foldername/index.html

or, ideally, I would like it to return

/myfolder/some-url.html
/myfolder2/index.html
/myfolder3/index.html
/foldername/index.html

I’ve tried

    var thisUrl = "" + window.location;
    var myRegExp = new RegExp("([^(\?#)]*)");
    thisUrl = myRegExp.exec(thisUrl);

but this returns

http://www.anydotcom.com/foldername/index.html,http://www.anydotcom.com/foldername/index.html

and I don’t quite understand why.

I appreciate any help here!

  • 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-12T07:16:06+00:00Added an answer on May 12, 2026 at 7:16 am

    If you are using window.location, you can simply access the wanted data by using:

    var thisUrl = window.location.pathname;
    

    If you are extracting stuff from links, the following regular expression will get you what you need:

    // Supports all protocols (file, ftp, http, https, whatever)
    var pathExtract = /^[a-z]+:\/\/\/?[^\/]+(\/[^?]*)/i;
    var thisUrl = (pathExtract.exec(someUrl))[1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a series of pattern Urls of the form: http://{username}.sitename.com/ http://{username}.othersite.net/ http://mysite.com/{username}
given series of DIVs w/unique ID as in: <div id=2988> <div class=site>YaHoot.com</div> <div class=logo>/images/yahootLogo.jpg</div>
Another developer has given me an algorithm that returns a series of strings that
I need to generate a series of N random binary variables with a given
Given this markup: // Calendar.html?date=1/2/2003 <script> $(function() { $('.inlinedatepicker').datepicker(); }); </script> ... <div class=inlinedatepicker
If I have a given series of numbers that count up by 1, say
Given a series of GPS coordinate pairs, I need to calculate the area of
Given a series of points, how could I calculate the vector for that line
Given a series of bits, what's the best way to overwrite a particular range
Is OpenGL, given a series of points, able to fill in a polygon or

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.