homepage regexp matching
I'm trying to write a regexp which allow me to filter out all the url addresses having this shape.
http://foo.com/
http://foo
http://foo.*
But not the following:
http://foo.com/subfoo
http://foo.com/subfoo/
http://foo.com/subfoo/subsubfoo..
In order to match the second url group i've written the following regexp:
http://.*/.
开发者_运维知识库However my problem is search the regexp matching the first group. So i need a way to say:
if after http://.* or http.//.*/ there is nothing, matches the pattern.
I've read something on lookhaead. I don't know it this might be the right way. Any idea? Thanks for your answer.
A bit late, but this worked for me:
http://[^/]*[/]*$
/^http:\/\/[^/?#]*\/./i
should match only http URLs with a path component other than /
.
Don't forget query strings like this: http://foo.com/?search
/^http:\/\/[^/?#]*\/[^?]/i
精彩评论