Happen to see a detailed explanation about this usage of regular expression in JavaScript: The Definitive Guide 6th Edition 10.2 String Methods for Pattern Matching
Recall that parenthesized subexpressions of a regular expression are
numbered from left to right and that the regular expression remembers
the text that each subexpression matches. If a $ followed by a digit
appears in the replacement string, replace() replaces those two
characters with the text that matches the specified subexpression
scala> """"{{"id":"1001"}}"""".replaceAll("""\"\{(.*?)\}\"""", "$1")
res15: String = {"id":"1001"}
The code above should solve you problem.
"""\"batters\": \"{{\"id\":\"1001\"}}\"""".replaceAll("""\"{(.*?)}\"""", "$1")?