To me, the error implies a problem with the Search phrase. But, the thing that hits me is in the replacement string. Instead of:
use:
Calibre's Editor (which uses the Python flavor or regex) uses \ instead of $ for replacement groups.
EDIT: In the Search phrase, I'd also try .+? instead of .*?. According to:
https://regex101.com/
.*? means:
"1st Capturing Group (.*?)
. matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)"
and
.+? means
"1st Capturing Group (.+?)
. matches any character (except for line terminators)
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)"
The difference being the lower number of matches (0 vs 1).