How to remove specific character from a string in Swift

How to remove specific character from a string in Swift

In this post we will give you information about How to remove specific character from a string in Swift. Hear we will give you detail about How to remove specific character from a string in SwiftAnd how to use it also give you demo for it if it is necessary.

we are going to learn how to remove the specific character from a given string inSwift.

Removing the specific character

To remove the specific character from a string, we can use the built-in remove() method in Swift.

The remove() method takes the character position as an argument and removed it from the string.

In this below example, we are removing the exclamation mark (!) from a given string.

var title  = "Play with! swift"if let i = title.firstIndex(of: "!") {    title.remove(at: i) // i is character index}print(title)

Output:

Play with swift

Hope this code and post will helped you for implement How to remove specific character from a string in Swift. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US