Skip to content

Instantly share code, notes, and snippets.

@tkausch
Created October 23, 2020 15:02
Show Gist options
  • Save tkausch/4973a6d149eba24d57cc1051d484946f to your computer and use it in GitHub Desktop.
Save tkausch/4973a6d149eba24d57cc1051d484946f to your computer and use it in GitHub Desktop.
How to remove prefix from string
extension String {
func deletingPrefix(_ prefix: String) -> String {
guard self.hasPrefix(prefix) else { return self }
return String(self.dropFirst(prefix.count))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment