开发者

Regular Expression to match relative URLs - II

开发者 https://www.devze.com 2023-01-11 12:25 出处:网络
Continue with the previous question, Regular Expression to match开发者_开发百科 relative URLs we are facing a slight problem with space in the relative Urls. Lets say, we have two scenarios:

Continue with the previous question,

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消