JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id='context'>設定檔</textarea>
<br>
<input type='text' value='起始值' id='base'></input>
<input type='button' value='更改' id='change'></input>
JavaScript
$('#change').click(function () {
var oldConfig = $('#context').val();
var idBase = parseInt($('#base').val(), 10);
function shiftBlockId(config, name, id, offset, string) {
var newNum = idBase++;
return name + '=' + newNum;
}
var format = /(I:\w+ID)\s?=\s?(\d+)/g;
var newCofig = oldConfig.replace(format, shiftBlockId);
$('#context').val(newCofig);
})