Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Expression Help

Status
Not open for further replies.

Trabjerg

Technical User
Nov 9, 2012
4
DK
Hi!

I'm using to create a JavaScript expression that I can use to validate a url.

^.*/[^\.]*$
The above approves the following
/myproduct/v2.2/hub/device_session.pdf

But I don't want it to approve the last .pdf, since this will allow ALL extension, and earlier in the Apache configuration I am validating extensions.

Can someone please help me with this?

Thanks

-M
 
maybe this
Code:
*\/)*([^\.]*)./ig]
would give better results as a pattern

_________________
Bob Rashkin
 
Thanks

Is this what you meant?

/([\w\d\.*\/)*([^\.]*)./ig]

I can't make it react on regexpal.com
What do you mean about pattern?

Thanks

-M
 
First, no. I don't know what happened with the code tags but somehow a "]"got dropped.
A pattern in RegExp-speak is the expression of what to look for within a string. In this case, it looks like you want to look for "any number, including 0, or letters, digits, or '.'": [\w\d\.]*, followed by a "/": [\w\d\.]*\/, repeated any number of times (hence the parentheses): ([\w\d\.]*\/)*. Then followed by any number of anything except "." followed by ".": ([^\.]*).

Since you didn't want to pick up the .pdf I figured you wanted to stop there. So
([\w\d\.]*\/)*([^\.]*).

_________________
Bob Rashkin
 
Ahh.... so nice. Thanks. I will test this tomorrow. And thanks for the explanation.

-M
 
Hi!

Well your solution seems to work, but since I use FileMatch in Apache, I learned how FileMatch really works. :) Anyway, I found a less advanced solution, and this works for now.

^v\d+.\d+$

Thank you for all your help

-M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top