let us = \"http://example.com\"
let range = us.rangeOfString(\"(?<=://)[^.]+(?=.com)\", options:.RegularExpressionSearch)
if range != nil {
let found = us.sub
In swift 3.0 rangeOfString
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
}
In latest swift 3.0 using Xcode 8 Beta 6 (latest updates to SDK):
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
}