小编Dev*_*ian的帖子

如何快速找到NSTextCheckingResult对象的子字符串?

我想知道如何从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

3
推荐指数
2
解决办法
4184
查看次数

标签 统计

swift2 ×1