What if you want to replace a _count_ number of occurrences of needle in haystack with nail? That's what Python's replace does, although I think that only works for strings in Python.