Quick Answer:
var coordPattern = /\[\s*\+?(-?)\s*0*(\d*\.?\d+)\s*,\s*\+?(-?)\s*0*(\d*\.?\d+)\s*\]/g;
var inputString = "This coord is [80,20] and [30,25]";
var outputString = inputString.replace(coordPattern, "<a href='location?x=$1$2&y=$3$4'>[$1$2,$3$4]</a>");
If you don't care about spaces
var coordPattern = /\[\+?(-?)0*(\d*\.?\d+),\+?(-?)0*(\d*\.?\d+)\]/g;
If you don't care about preceding plus or minus signs
var coordPattern = /\[\s*()\s*0*(\d*\.?\d+)\s*,\s*()\s*0*(\d*\.?\d+)\s*\]/g;
If you don't care decimals
var coordPattern = /\[\s*\+?(-?)\s*0*(\d+)\s*,\s*\+?(-?)\s*0*(\d+)\s*\]/g;
If you care about preceding zeros
var coordPattern = /\[\s*\+?(-?)\s*(\d*\.?\d+)\s*,\s*\+?(-?)\s*(\d*\.?\d+)\s*\]/g;
If you want it all!...Wealth. Women. And one more thing...
var coordPattern = /\[\s*\+?(-?)\s*0*(\d*\.?\d+)\s*,\s*\+?(-?)\s*0*(\d*\.?\d+)\s*\]/g;
Test code
var coordPattern = /\[\s*\+?(-?)\s*0*(\d*\.?\d+)\s*,\s*\+?(-?)\s*0*(\d*\.?\d+)\s*\]/g; // If you want it all!...Wealth. Women. And one more thing...
var testStrings = [
"This coord is [80,20] and [30,25]",
"This coord is [80 ,20] and [30, 25]",
"This coord is [ 80,20] and [30,25 ]",
"This coord is [-80,20] and [+30,25]",
"This coord is [1.23,20] and [30,4.56]",
"This coord is [-.123,20] and [+0.456,25]"
];
var expectedAnswers = [
"This coord is <a href='location?x=80&y=20'>[80,20]</a> and <a href='location?x=30&y=25'>[30,25]</a>",
"This coord is <a href='location?x=80&y=20'>[80,20]</a> and <a href='location?x=30&y=25'>[30,25]</a>",
"This coord is <a href='location?x=80&y=20'>[80,20]</a> and <a href='location?x=30&y=25'>[30,25]</a>",
"This coord is <a href='location?x=-80&y=20'>[-80,20]</a> and <a href='location?x=30&y=25'>[30,25]</a>",
"This coord is <a href='location?x=1.23&y=20'>[1.23,20]</a> and <a href='location?x=30&y=4.56'>[30,4.56]</a>",
"This coord is <a href='location?x=-.123&y=20'>[-.123,20]</a> and <a href='location?x=.456&y=25'>[.456,25]</a>"
];
for(var i = 0; i < testStrings.length; ++i){
var inputString = testStrings[i];
var expectedString = expectedAnswers[i];
var outputString = inputString.replace(coordPattern, "<a href='location?x=$1$2&y=$3$4'>[$1$2,$3$4]</a>");
jQuery('body').append(
jQuery('<span>').append([
'--test-passed=' + (outputString === expectedString),
'--input="' + inputString + '"',
'--output=', outputString
].join('')
),
jQuery('<br/>')
);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>