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!

regular expression for directory structure 1

Status
Not open for further replies.

MiMoore

Programmer
Aug 25, 2005
12
IE
hi.

I'm trying to validate an input in the form of directory structure.

the directory has to be start with /forms/guide and can also have any sub direcotry existing off it.

the following would be valid entries
/forms/guide
/forms/guide/
/forms/guide/test

I have tried with no luck the following.
Code:
^/forms/guide([/]?$|/[.*]?$)
^/forms/guide([/]?|/[.*]?)$

/forms/guide_test should be prohibited but is allowed.

While the first option seems to work, the second option of the OR is not picked up.

I would appreciate any help on best way to do this. thanks.

 
[/]? will succeed either way. It will accept a '/', but it will be satisfied with nothing.

try:
Code:
^/forms/guide(/[^/]*)?$
Untested though :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top