【发布时间】:2026-01-28 11:20:24
【问题描述】:
我希望将用户输入的字符串与其他 3 个字符串进行比较。如果用户输入的字符串包含其他字符串包含的任何字符,我想做一件事,如果不是别的事情
案例 1: 字符串1 = abc 字符串 2 = abc string3 = abc
userEnter = fgh
> since none of the letters match do one thing
案例 2: 字符串1 = abc 字符串2 = fbc string3 = abc
userEnter = fgh
> one letter from userEnter is found in the other 3 strings do another thing...
完全不知道如何快速比较字符串或如何访问单个字符。我习惯了 C 中的一切都是 char 数组..
【问题讨论】:
-
简单的
==有效吗?例如,if str1 == str2。
标签: arrays string swift character