Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

URL Parsing Regular Expression

Avatar of nbcit
nbcit asked on
Regular Expressions
30 Comments1 Solution802 ViewsLast Modified:
I need a regular expression to return a match in the following conditions:

Between the last slash (/) of a URL and either the end of the string (with no GET statement) or the ? (with a GET statment), return a match if the contents DO NOT include a period (.).  The expression should not match if there is nothing between the last slash (/) and the end of the string or ? mark.

Basically I am trying to determine whether the URL looks like it is directed at a folder (instead of a page) but missing the trailing folder slash (/).  I will not be using the returned match(s), but merely seeing if there were matches or not.  I believe the Reg Expression engine I am using is based on the Perl syntax.

The incoming URL could be any of the following patterns (matched or no match included):
/  (no match)
/?var1=1&var2=2   (no match)
/folder  (match)
/page.asp  (no match)
/page.asp?var1=1&var2=2  (no match)
/folder1/folder2  (match)
/folder1/folder2?var1=1&var2=2  (match)
/folder1/page.asp  (no match)
/folder1/page.asp?var1=1&var2=2  (no match)

Thanks everyone!
Avatar of Richard Quadling
Richard QuadlingFlag of United Kingdom of Great Britain and Northern Ireland imageSenior Software Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 30 Comments.
See Answers