我想知道如何从NSTextCheckingResult对象中找到子字符串。到目前为止,我已经尝试过了:
import Foundation {
let input = "My name Swift is Taylor Swift "
let regex = try NSRegularExpression(pattern: "Swift|Taylor", options:NSRegularExpressionOptions.CaseInsensitive)
let matches = regex.matchesInString(input, options: [], range: NSMakeRange(0, input.characters.count))
for match in matches {
// what will be the code here?
}
Run Code Online (Sandbox Code Playgroud) swift2 ×1