Swift: How to get substring from start to last index of character

前端 未结 22 822
感情败类
感情败类 2020-11-30 19:09

I want to learn the best/simplest way to turn a string into another string but with only a subset, starting at the beginning and going to the last index of a character.

22条回答
  •  再見小時候
    2020-11-30 19:44

    Here is a simple way to get substring in Swift

    import UIKit
    
    var str = "Hello, playground" 
    var res = NSString(string: str)
    print(res.substring(from: 4))
    print(res.substring(to: 10))
    

提交回复
热议问题