I need to search a string and edit the formatting of it.
So far I can replace the first occurrence of the string, but I am unable to do so with the next occurrences
Use std::regex_replace available with C++11. This does exactly what you want and more.
https://en.cppreference.com/w/cpp/regex/regex_replace
std::string const result = std::regex_replace( chartDataString, std::regex( "\\*A" ), "[A]\n" );