Skip to content

Instantly share code, notes, and snippets.

@arch-jslin
Created May 12, 2010 09:47
Show Gist options
  • Save arch-jslin/398397 to your computer and use it in GitHub Desktop.
Save arch-jslin/398397 to your computer and use it in GitHub Desktop.
r = Regexp.new(
'( (http|https|ftp)://)*'+ #protocol:// 可有可無
'( (\d{1,3}\.){3,3}\d{1,3}|'+ #第二段,這邊可能是 IPv4
'((-|\w)+\.)+(tw|com|aero|us|gr)|'+ #或正常suffix的DN
'((-|\w)+\.)*localhost )'+ #或localhost
'(:\d{1,5})?'+ #:port number
'(/\S+)*', Regexp::EXTENDED) #第一個 / 後面就不管他了
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment