Q:

Replace brackets from a number in following format ($n) e.g. ($57,282,341.26) with -$57,282,341.26 using regular expression

I was working on Globalization currency formatting and I came through an issue where all the currency values in minus is showing brackets instead of minus symbol eg.-$57,282,341.26  is being shown as ($57,282,341.26). 
    Now I wanted to make a global search and replace on such type of strings. So that I could get results as -$57,282,341.26
I tried:
var str = "This sentence contains ($57,282,341.26) "; 
var patt1 = /(\()+(\$)+([0-9,.]+)+(\))/g;
var result = str.match(patt1);
document.getElementById("demo").innerHTML = result;

I am able to find number in ($n) format but I couldn't do replace with back reference. 

A:

You may use
var result = str.replace(/\((\$[0-9][.,0-9]*)\)/g, '-$1');

See the regex demo
Details:

\( - a literal ( char
(\$[0-9][.,0-9]*) - Group 1 capturing $, a digit and then 0+ digits, . or , chars
\) - a literal ) char.

The -$1 replacement pattern contains a literal - symbol and the $1 backreference to the value kept in Capturing group 1.

var str = "This sentence contains ($57,282,341.26) "; 
var patt1 = /\((\$[0-9][.,0-9]*)\)/g;
var result = str.replace(patt1, "-$1");
console.log(result);

