What's the best way to go about removing the first six characters of a string? Through Stack Overflow, I've found a couple of ways that were supposed to be solutions but I noticed an error with them. For instance,
extension String {
func removing(charactersOf string: String) -> String {
let characterSet = CharacterSet(charactersIn: string)
let components = self.components(separatedBy: characterSet)
return components.joined(separator: "")
}
If I type in a website like https://www.example.com
, and store it as a variable named website, then type in the following
website.removing(charactersOf: "https://")
it removes the https://
portion but it also removes all h's, all t's, :'s, etc. from the text.
How can I just delete the first characters?