How to properly use indexes and ranges in Swift to isolate substrings
I want to find the last occurance of either of two characters in a string and then create a substring with all of the characters that follow. For example given the string: This is my + string with +GetThisSubstring I want the substring to be 'GetThisSubstring' Or if the string is: This is my / string with /GetThisSubstring I want the substring to also be 'GetThisSubstring' I tried using indexes and ranges, but just could not seem to get it right. I have done a lot of searching and reading (not here on Sololearn as there is very little Swift Q&A content). I ended up using a different approach (see below) but would like to understand how to use indexes and ranges to access substring of strings. let theText = readLine()! var textPart = "" for c in theText.reversed() { if c == "+" || c == "/" {break} textPart += String(c) } print(String(textPart.reversed())) // GetThisSubstring