views:

19

answers:

1

Continue with the previous question,

http://stackoverflow.com/questions/3447131/regular-expression-to-match-relative-urls

we are facing a slight problem with space in the relative Urls. Lets say, we have two scenarios:

/abc/part%20Red/

/abc/part Red/

First relative URl is retrived but second relative URL returned /abc/part instead of /abc/part Red/

We cann't add \s in our allowed character list. If we add \s in the allowed character list, we may get more wrong Urls.

A: 

The problem you have is that spaces are not allowed in URLs, only %20. It is impossible to tell whether text after a space is part of the URL or not. Take the following example:

Go to /user/docs/document and look in sections 3/5
Go to /user/docs/document with spaces and look in sections 3/5

There is no way to programmatically tell which words are part of the URL and which are just words.

Ryan Mentley
@LordArtemis: Thanks for the reply. Not able to get your example. Can you please explain.
Malik
I assume you are trying to parse URLs out of text, so I gave some examples of URLs surrounded by text.In the first one, the URL is `/user/docs/document` while in the second one, it is `/user/docs/document with spaces`. However, there is no way to tell this from looking at it.
Ryan Mentley