Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func grabCity(_ str: String) -> String {
- // let regex = try! NSRegularExpression(pattern: "(\\w+)(?!.*\\w)", options: [])
- let regex = try! NSRegularExpression(pattern: "(?<=\\[)(.*?)(?=\\])", options: [])
- let result = regex.matches(in: str, options: [], range: NSRange(location: 0, length: str.count)).last
- return result.map{ String(str[Range($0.range, in: str)!]) }!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement