LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-23-2005, 11:45 AM   #1
ninjabob7
Member
 
Registered: Nov 2005
Distribution: Ubuntu 9.10 and Slackware 13.1
Posts: 78

Rep: Reputation: 15
How to separate URLs with JavaScript?


I am making a "control panel" section for my website that allows me to upload files, edit pages, etc. It uses a combination of JavaScript and PHP on a Linux server. The main page is a page that lists all the folders and files in a directory. I've already made the code to edit, view, and delete files, as well as descend into folders. Now I need to finish the code to descend into folders. When I click on the "../" folder, it adds "../" to the path instead of going up a directory. How do I strip off the last part of the url, which looks like this: foo/bar/ using JavaScript?
 
Old 11-23-2005, 03:57 PM   #2
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
there might be a prettier regex, but this one will work...
Code:
var addr = "/foo/dir1/dir2/dir3/dir4";
addr = addr.replace(/(\/.+)\/.+$/, "$1");
i tested it in my browser and it works...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Request for URLs Paone Linux - Newbie 2 03-29-2005 04:09 PM
how to check urls and stop internet urls in network gface Linux - Networking 5 03-24-2005 09:48 PM
Separate Partitions for Separate User groups volvic Slackware - Installation 2 09-16-2004 02:42 AM
.urls mikedelo Linux - Newbie 5 03-29-2004 05:32 PM
swaret -- urls elluva Slackware 2 01-16-2004 10:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration