Search code examples
regexruby-1.8.7

regex to match everything except protocol from url


I have the following regex pattern: (?:http.?:\/\/)

This matches the protocol component from a web url, I want a regex to do the opposit, to match everything except the protocol, so far my every attempt has not worked at all.

Becuase ultimatly what I want to do is check if two urls are the same reguardless of protocol, so I can do:

if url_1[regex] == url_2[regex]

Solution

  • This should do it:

    /.*?\/\/(.*)/