RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Absolute Path
Expression
^((?:\/[a-zA-Z0-9]+(?:_[a-zA-Z0-9]+)*(?:\-[a-zA-Z0-9]+)*)+)$
Description
An overly simple UNIX based path regex. The path must begin with a forward slash. The path segments may not lead or end with an underscore or dash which is a good thing. They also can not be doubled (__ or --). Another good thing. I've omitted all the punctuation that RFC allows until further notice.
Matches
/users/web/mysite/web/cgi-bin
Non-Matches
/users/web/my site/web/cgi-bin | users/web/mysite/web/cgi-bin/
Author Rating: The rating for this expression. tedcambron
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: A little better
Name: Ted Cambron
Date: 2/8/2008 9:36:27 PM
Comment:
I fixed it so the path segments can not begin or end with an underscore or dash nor can they be doubled (__) (--). I prefer not to add any more symbols unless someone can suggest so that understands the purpose of this regex.


Title: Hi Randal
Name: Ted Cambron
Date: 2/6/2008 10:47:54 PM
Comment:
I just read RFC2396, and I found it somewhat helpful but still a little confusing for me. What I need here is an "abs_path" only thingy. I guess I could add the "marks" to include all the unreserved characters but I really want to leave out :, @, &, =, +, $, & "," for this purpose. The thing I don't understand is the difference between "param" and "pchar" in a segment. Please advise. Master. Can I email you?


Title: Why are you ignoring the standard?
Name: Randal L. Schwartz
Date: 2/3/2008 6:27:01 PM
Comment:
Have you never seen http://www.faqs.org/rfcs/rfc2396.html ? There are far more characters permitted in a URI than you list. Get a clue, sir.


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials