Say I want to extract all numbers from a string (Most likely using regex matching) and I also want to replace those number matches with a generic placeholder like "#".
This is easily done in two parts using FindAll, then ReplaceAll. However I have serious doubts about the performance costs of doing such operations.
So take a string
"sdasd 3.2% sadas 6 ... +8.9"
replace it with
"sdasd #% sadas # ... +#"
and get a slice
[3.2,6.0,8.9]
In the most performant way possible.
Edit : I implemented the regexp.FindAllString + regexp.ReplaceAllString and the performance hit to my app was very minimal. I will hopefully try Elliot Chance's approach and compare the two when I have time.