try? NSRegularExpression(pattern: "[^a-z0-9]", options: NSRegularExpressionOptions.CaseInsensitive) let range = NSMakeRange(0, s.characters.count) let alphanums = reg!.stringByReplacingMatchesInString(s, options: NSMatchingOptions(rawValue:0), range: range, withTemplate: "").lowercaseString let rev = alphanums.characters.reverse() for (a,b) in zip(alphanums.characters, rev) { if a != b { return false} } return true }