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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:03:06+00:00 2026-06-05T18:03:06+00:00

Totally new to programming so kindly excuse the silly question. I have this URL

  • 0

Totally new to programming so kindly excuse the silly question.
I have this URL http://www.blahblah.com/some/thing/blah..

Now i need the string that appears after the third”/” ie., just “/some/thing”..
I dont want to go from reverse as the URL is different for each page but the protocol and the host name is the same..
Is there a way i can extract “/some/thing” along using Javascript..
Appreciate any help..
Thanks!!

  • 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-05T18:03:07+00:00Added an answer on June 5, 2026 at 6:03 pm

    I would use a simple regular expression here.

    One way to get stuff after the third “/” just throw it away with everything before it.

    Basic idea:

    "/a/b/c/d/e/f".replace(/.*?\/.*?\/s.*?\//, "")
    // -> "c/d/e/f"
    

    Alternative #1, to reduce repeat:

    "/a/b/c/d/e/f".replace(/(?:.*?\/){3}/, "")     
    

    Alternative #2, if input can contain newlines:

    "/a/b/c/d/e/f".replace(/(?:[^\/]*\/){3}/, "")
    

    The *? qualifier means “don’t be greedy” so . won’t skip over /‘s. It’s not needed in the negative character class case because [^\/] will never match /.

    This could of course be written in a “less generic” form because because the real intent is just to git rid of the protocol/domain portions of the URI (the number of /‘s is only an observed relationship):

    "http://foo/a/b/c/d/e/f".replace(/https?:\/\/[^\/]*\/?/i, "")
    // -> "a/b/c/d/e/f"
    

    Note that the last \/ has a ? after it so it will return “” for “http://foo” and the i is so it will match HTTP:// if that is used for some strange reason (completely optional, of course).

    "HTTPS://foo".replace(/https?:\/\/[^\/]*\/?/i, "")
    // -> ""
    

    Happy coding!


    Note: all of the above regular expressions will extract the content after the 3rd /, as stated in the question. They will need to be slightly modified to include the 3rd / in the result. Also, it helps to not ask X-Y questions.

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

Sidebar

Related Questions

I´m totally new to programming in java, and following some basic tutorials for my
I am totally new to programming and to some new technologies. Right now I
I am totally new to programming. I´m reading some tutorials on the internet, and
So, I am totally new with CGI programming in Perl. The question is simple.
I am totally new to programming and I have chosen Delphi as the programming
I have two years of experience on iPhone programming but totally new to OpenGL.
i have a question because i am fairly new to python, socket programming and
My question is straight forward. I'm totally new to the Microsoft stack, I have
Totally new to python, and i want to do the following: I have this
I am totally new to math/numerical analysis programming and I was looking all over

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.