Find the nth occurrence of substring in a string
Mark’s iterative approach would be the usual way, I think. Here’s an alternative with string-splitting, which can often be useful for finding-related processes: And here’s a quick (and somewhat dirty, in that you have to choose some chaff that can’t match the needle) one-liner: