no veo por que te falla pero aqui va un ejemplo.
Código:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Test Development</title>
<script type='text/javascript'>
self.onload = function(){
alert("left {%c1%} right {%c2%}".replace(/\{%(\w+)%\}/g, function(){
return document.getElementById("cmp"+arguments[1]).value;
}));
};
</script>
<style type='text/css'>
</style>
</head>
<body>
<input id="cmpc1" value="center" />
<input id="cmpc2" value="final" />
</body></html>