My main string is \"hello Swift Swift and Swift\" and substring is Swift. I need to get the number of times the substring \"Swift\" occurs in the mentioned string.
T
Try this
var mainString = "hello Swift Swift and Swift" var count = 0 mainString.enumerateSubstrings(in: mainString.startIndex..