Here's a simple code that let us find out if a string contains a dot
characters (we don't know how many, we just know that it contains it):
var number: String = "3.14"
if number.contains(".") {
print("The string contains a dot character")
} else {
print("There's no dot character")
}
But imagine a situation where user wrongly puts 2 or 3 dots in a line, like this:
var number: String = "3...14"
How to check whether a string contains one dot
or several ones?
How to count all the dots in the string?