I am very new to Swift and have trying to use regular expressions, but getting the match from the string seems to be an insurmountable task.
This is my current approach.
print(data.substring(with: (data.range(of: "[a-zA-Z]at", options: .regularExpression))))
This doesn't work because
Value of optional type 'Range<String.Index>?' must be unwrapped to a value of type 'Range<String.Index>'
I guess this has something to do with it possibly being null, so now i want to provide it with an alternative using the ?? operator.
print(data.substring(with: (data.range(of: "[a-zA-Z]at", options: .regularExpression) ?? Range<String.Index>())))
What i want to do is to provide it with an empty range object but it seems to be impossible to create an empty object of the type required.
Any suggestions?