Swift 4 – Substring!

let stripped = "FREMP my string" // my string
let indexOf = stripped.index(stripped.startIndex,offsetBy:5)
let sub = stripped[..<indexOf] //left cut -> output: "my string"
print("sub")

//sub is of type substring - to make it a string again just type:
let stringAgain = String(sub)

Leave a Reply

Your email address will not be published. Required fields are marked *