我习惯使用JavaScript来做这件事:var domains = "abcde".substring(0, "abcde".indexOf("cd")) // Returns "ab" Swift 没有这个函数,如何做类似的事情?