Search & Replace All in Strings
One common task when working with text in code, is searching and replacing inside strings. For example you might want to replace X with Y. Or equally, you might want to replace Z with nothing, removing it. In this blog post, we’ll explore two ways to perform a search and replace operation in Go using the strings and regexp packages.
Strings Package The strings package provides a simple method called Replace() for search and replace operations. This method has the following signature: