I’m using boost::regex_replace(replacement_text, regex, new_text) function to do this…
replacement_text = "{replace_me}"
regex = "(\{([^\}]*[^\s]*)\})"
new_text = "$$$"
For every new_text that doesn’t contain “$”, this works beautifully, new_text would completely replace the replacement_text. But when using the symbol “$$$”, it truncates it to “$$”, taking off 1 $.
I read that the dollar sign ($) in the specs are for special formatting:
$n
n-th backreference (i.e., a copy of the n-th matched group specified with parentheses in the regex pattern).
n must be an integer value designating a valid backreference, greater than 1, and of two digits at most.
So how can I disable this so that it doesn’t do special formatting? Thanks in advance!
As you mentioned in your question,
$is an escape sequence in formatter parameter ofregex_replace, so like any other special character in PCRE(Perl compatible regex) you can escape it using\! so use\$\$\$and since you are using C++ you should use\\$\\$\\$(of course you know that already)