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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bootstrap Form 16 37
dynamic created check uncheck boxes 6 41
Javascript Regex 7 20
Sending ASP to server side 8 28
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (, we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

685 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