JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="input">.coord('350','300')</textarea>
<button id="btn">Test Regex</button>
<textarea id="output"></textarea>

CSS

textarea, button{float:left;margin:10px auto;clear:both}
textarea{width:100%;min-height:80px}

JavaScript

$('#btn').click(function() {
    testReg($('#input').val(), $('#output'));
});

//array of regex pattern and replacement //just one for the example
var regexes = [ //FORMAT is array of [PATTERN,REPLACEMENT] /*.coord("X","Y")*/ 
    [/\.coord\(['"]([\w]+)['"],['"]?([\w:\.\\]+)['"]?\)/g, '$1 * $2']
                     ];

function testReg(inputText, $output) {
    //using regex
    for (var i = 0; i < regexes.length; i++) {
        $output.val(inputText.replace(regexes[i][0], function(match, $1, $2, $3, $4) {
            var checkedValues = checkReplace(match, $1, $2, $3, $4);
            $1 = checkedValues[0];
            $2 = checkedValues[1];
            regexes[i][1] = regexes[i][1].replace('$1', $1).replace('$2', $2);
            return  regexes[i][1];
        }));
        inputText = $output.val();
    }
}

function checkReplace(match, $1, $2, $3, $4) {
    console.log(match + ':::' + $1 + ':::' + $2 + ':::' + $3 + ':::' + $4);
    if ($1 > 200) $1 = parseInt($1 / 2);
    if ($2 > 200) $2 = parseInt($2 / 2);
    return [$1,$2];
}