I know how to remove first character from a word in swift like this:
var data = "CITY Singapore"
data.removeFirst()
print(data)//ITY Singapore
what i want is to remove the first word and space so the result is "Singapore".
How can i remove the first word and leading space in swift?
4
Answers
You can try
Or
Or you can go with this too
This is a Regular Expression solution, the benefit is to modify the string in place.
The pattern searches from the beginning of the string to the first space character
You can use String’s
enumerateSubstrings
in range method (Foundation) usingbyWords
option and remove the first enclosing range. You need also to stop enumeration after removing the range at the first occurrence: