// GraalJS Script (engine type: 2)
//
// Notes:
// Regular expressions cannot be used in the search string.
// Can also replace strings that include line breaks and tabs.
//
// Notes (ja):
// 検索文字列の設定に正規表現は利用できません。
// 改行コードやタブコードを含む文字列も置換可能です。
//////// START "main()" ////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const strA = configs.get( "conf_StrA" ) + ""; // required
const strSub = configs.get( "conf_StrSub" ) + ""; // required
const strNew = configs.get( "conf_StrNew" ) + ""; // required
const dataIdD = configs.get( "conf_DataIdD" ) + ""; // required
engine.log( " AutomatedTask Search: " + strSub );
engine.log( " AutomatedTask Replacement " + strNew );
//// == Data Retrieving / ワークフローデータの参照 ==
// (nothing, except Expression Language config)
//// == Calculating / 演算 ==
// Escaping for a literal string search
// For a wider range of values, comment out and use Patterns with special characters
let myMatch = new RegExp( strSub
.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&')
, 'g' ); // global match
let strOutput = strA.replace( myMatch, strNew );
//// == ワークフローデータへの代入 / Data Updating ==
engine.setDataByNumber( dataIdD, strOutput );
} //////// END "main()" ////////////////////////////////////////////////////////////////