我将使用正则表达式从这样的复杂输入中提取子字符串。
Swift 3.1:
let test = "javascript:getInfo(1,'Info/99/something', 'City Hall',1, 99);"if let match = test.range(of: "(?<=')[^']+", options: .regularexpression) { print(test.substring(with: match))}// Prints: Info/99/somethingSwift 2.0:
let test = "javascript:getInfo(1,'Info/99/something', 'City Hall',1, 99);"if let match = test.rangeOfString("(?<=')[^']+", options: .RegularexpressionSearch) { print(test.substringWithRange(match))}// Prints: Info/99/something


