I am trying to extract a partial String from a given input String in Swift5. Like the letters 2 to 5 of a String.
I was sure, something as simple as inputString[2...5]
would be working, but I only got it working like this:
String(input[(input.index(input.startIndex, offsetBy: 2))..<(input.index(input.endIndex, offsetBy: -3))])
... which is still using relative positions (endIndex-3 instead of position #5)
Now I am wondering where exactly I messed up.
How do people usually extract "cde" from "abcdefgh" by absolute positions??