Não consigo incluir o símbolo 'em Expressões regulares
Tento incluir o símbolo 'em Expressões regulares
Eu uso essa função
func matches(for regex: String, in text: String) -> [String] {
do {
let regex = try NSRegularExpression(pattern: regex)
let results = regex.matches(in: text,
range: NSRange(text.startIndex..., in: text))
return results.map {
text.substring(with: Range($0.range, in: text)!)
}
} catch let error {
print("invalid regex: \(error.localizedDescription)")
return []
}
}
e esta Expressões regulares
let matched = matches(for: "^[‘]|[0-9]|[a-zA-Z]+$", in: string)
quando procuro, encontro números e letras em inglês
mas não' símbolo