Validate the path of an url

I'm trying to validate an url without domain, just the path and params.

The regular expression that I'm using do most of the work, but It has some errors that I dont know how to prevent (I'm pretty noob with regexp):


The next example are correctly validated

/asd.jsp -> true
/asd/asd.jsp -> true
/asd/asd.jsp?bar=baz&inga=42&quux -> true
/asd/asd.jsp?bar=ba z&inga=42&quux -> false

But this ones arent correct ulrs and them gives me true too:

/asd/asd./jsp -> true :(
/asd/asd.jsp/ -> true :(
/asd./asd.jsp -> true :(
/asd///asd.jsp -> true :(
/asd/asd.jsp&bar=baz?inga=42?quux -> true :(

Do you recommend to use a function instead of a regex?

Very much thanks!


Try this:


I already escaped special characters, so you can directly use it in java. By the way, /asd/asd.jsp?bar=baz&inga=42&quux is not a valid URL.

Unescaped Regex:







Need Your Help

Create an array of integers property in Objective C

objective-c arrays properties

I'm having troubles creating a property of an array of integers in Objective C.

When requesting com port returns the same request

java serial-port at-command jssc

I`m trying to send AT-command via COM-port, but reseived only the same command.