I am new to Swift 4 and practising swift. I am not able to figure out how to find a index of a particular substring inside a string. Below is code :
var hello = "Hello This is HelloWorld !"
if let idx = hello.characters.index(of: "!") {
hello.insert(contentsOf: ", world".characters, at: idx)
}
I need a function which return me "HelloWorld" index from var hello. I think there should be inbuilt function but i couldnt find it. i Have seen this post of stack overflow Index of a substring in a string with Swift but most of code is outdated. please help me to sort this .