Regular Expression match in Javascript

Posted on 2011-02-14
Last Modified: 2012-05-11
Can you please let me know how I can express the following line using regular expressions in JavaScript?

The "anystring" can be anything, either a letter or a number and I don't know how many times it will repeat itself between slashes.

I want to match the part using regular expressions in JavaScript to the end of the directory where anystring.html HTML file locates.


Now I want to match:

Again, I don't know how many sub directories there are until mychecks.html file.


Question by:Tolgar
LVL 35

Expert Comment

by:Terry Woods
ID: 34891621

Expert Comment

ID: 34891661
LVL 16

Accepted Solution

sjklein42 earned 250 total points
ID: 34891670

Open in new window

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34891782
Another option:
var input = "";


Open in new window

LVL 16

Expert Comment

ID: 34891957
re kaufmed's solution, I don't think we're supposed to include the filename part of the file, which I believe your pattern does.  You are excluding the filetype but not the filename.
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34892089
Indeed. I read the example's output incorrectly. Good eye  = )

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question