我必须在字符串中找到3个字符中的1个。我怎样才能做到这一点?查找字符串中的3个字符中的1个
我尝试这样做:
let value = "from 3,95 €"
let wanted: Character = "£", "€" OR "₹"
if let idx = value.characters.index(of: wanted) {
print("Found \(wanted)")
} else {
print("Not found")
}
谢谢!
你只是想检查字符串是否有该字符,或者你想要该字符的索引吗? –
为什么你不使用'NSNumberFormatter'的任何理由?选中这个[documentation](https://developer.apple.com/documentation/foundation/numberformatter)。 – LinusGeffarth
@Nirav D:是的,我只想检查一个字符串中是否有这些字符。不,我不需要索引.... – Saintz