There are multiple problems here. First, regex_replace takes a basic_regex as the second parameter. Second, it doesn't perform the replace in-place, but returns a new string. Finally, you have some unnecessary parenthesis in your regular expression. So your code should look like this:
string input = "well, $<hello>$ there!";
std::regex reg("\\$<.+>\\$");
// prints "well, fellow there!":
std::cout << '\n' << std::regex_replace(input, reg, "fellow") << '\n';
Note that word boundary check (\\b) is not going to work here because the start and end characters of the sequence are dollar signs, and \\b marks word boundary, which means either
- The beginning of a word (current character is a letter, digit, or underscore, and the previous character is not)
- The end of a word (current character is not a letter, digit, or underscore, and the previous character is one of those)
regex_replace()as an example of what you are trying to do?