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:
tedcambron
|
Source |
|
Your Rating |
|
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.