我正在寻找更好的解决方案。
我的字符串只包含数字和字母,例如“ 123blue321car”,我想将其拆分为列表(“ 123”,“ blue”,“ 321”,“ car”)。
我有一个非常糟糕的解决方案:遍历字符串,添加逗号,然后再使用.Split()和逗号作为分隔符。但是我想知道这是否好吗?有更好的主意应对吗?
答案 0 :(得分:2)
您可以使用正则表达式拆分字符串,以下是示例:
activityIndicator.center = self.view.center
activityIndicator.hidesWhenStopped = true
self.view.addSubview(activityIndicator)