I receive a json array of strings from an external source and some of my string look like
"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00"
I would like to filter out all strings that only contain these null values. I've tried this
arr = arr.filter { (str: String) -> Bool in
let invalid = String(data: Data.init(count: str.count), encoding: String.Encoding.utf8)
print(str)
return str == invalid
}
Since these are all null terminators, i decided to create a null string of the same length as str but only containing null terminators and compare them.
But this doesn't work. Any help will be appreciated.
xfollowed by 2 zeros.