looking for some solutions? You are welcome.

SOLVED: Swift: Checking Prefix with Regex


I am attempting to check if a string begins with a text that follows a regex pattern. Is there a way to do so using string.hasPrefix()?

My implementation so far:

let pattern = "[Ff][Yy][Ii](.)?"
let regex = try? NSRegularExpression(pattern: pattern, options: [])

if firstRowText.hasPrefix(regex) { //Cannot convert value of type NSRegularExpression to String


Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: