let us = \"http://example.com\"
let range = us.rangeOfString(\"(?<=://)[^.]+(?=.com)\", options:.RegularExpressionSearch)
if range != nil {
let found = us.sub
In swift 3.0rangeOfString syntax changed like this.
let us = "http://example.com"
let range = us.range(of:"(?<=://)[^.]+(?=.com)", options:.regularExpression)
if range != nil {
let found = us.substring(with: range!)
print("found: \(found)") // found: example
}