Is any other ways to parse string \"from-to\"? I mean when there is a value we need and we know about string before and after it. I`ve just created such functi
You could do something like this using substringWithRange
:
func substringBetween(start: String, and end: String) -> String? {
if let startIndex = rangeOfString(start, options: .LiteralSearch, range: nil, locale: nil)?.endIndex,
endIndex = rangeOfString(end, options: .LiteralSearch, range: startIndex..<self.endIndex, locale: nil)?.startIndex {
return substringWithRange(startIndex..<endIndex)
} else {
return nil
}
}