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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:02:13+00:00 2026-05-29T08:02:13+00:00

My page’s URL is like this: http://www.mydomain.com/directory/thisismy_page.html Using JavaScript, I want to pull out

  • 0

My page’s URL is like this:

http://www.mydomain.com/directory/thisismy_page.html

Using JavaScript, I want to pull out the part of the page’s filename before the underscore. So in this example, I want:

thisismy

I currently have this:

var filename = location.pathname.substring(location.pathname.lastIndexOf("/") + 1);

But that pulls out thisismy_page.html. How do I “stop” it at the underscore so all I get is thisismy?

  • 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-29T08:02:14+00:00Added an answer on May 29, 2026 at 8:02 am
    filename=filename.split("_")[0];
    

    This splits it at the underscore and takes the first (or 0th part).

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

Sidebar

Related Questions

On page 88 of Stephen Toub's book http://www.microsoft.com/download/en/details.aspx?id=19222 There is the code private BlockingCollection<T>
page I'm working with: http://jsbin.com/abewe4 I want the slogan div centered inside col3 div
Page - http://blu-eye.com/index.html - contains suckerfish menu which is displaying correctly on the rest
page.getByXPath(//*[@href='http://www.example.com/index.do/abc/1_*'); Do I need to escape any characters? I am trying to get all
Page in question: http://www.rjlacount.com/public/lander/ I'm probably just doing something stupid, but I'm trying to
This page describes all steps to edit RC: http://msdn.microsoft.com/en-us/library/dd456813.aspx Those are easy steps, pretty
Page not found (404) Request Method: GET Request URL: http://beta.mysite.com/admin/filebrowser/ The requested admin page
Page link I am working on is http://www.whatcar.com/car-news/subaru-xv-review/260397 I am trying to automate 'clicking
Page I'm working with is: http://cloudninetech.com/newsite/site/homepage.html Notice the tab slider at the bottom. I
Page in question: http://phwsinc.com/our-work/one-rincon-hill.asp In IE6-8, when you click the left-most thumbnail 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.