I’ve stubbed out changes in the performAction function that will update the action field with regex substitutions. It took some Innerweb hunting to pin down the proper use of regex group and the substitution format ( some docs said \1,\2 etc others $1,$2 (which is working)
AutoCat sheet entries
Line 91: says to match any digit followed by a letter and put a space inbetween
Line 92: (probably redundant):says look for a digit jammed next to ‘at’
Also specific to my situation, I get Descriptions with words jammed together, so I added another action type – replace. This action uses the string replace method to modify the target field. Unfortunately, the list I work against is rather long so the load and execution is a bit sluggish.
Modified code for performAction
switch (rule.action) {
case "set":
//console.log(rule)
//console.log(rowData)
yap(`${rule.actionColumn}[${rowNum}]="${rule.actionValue}"`);
// console.log("Comparison:", rule.comparison)
switch(rule.comparison) {
case "matches regex":
//const have = ${rule.actionColumn}[${rowNum}]
//const replace = r.value.replace("/".${rule})
// console.log(rule);
//console.log(rowData);
const val=rowData[column]
const nval=val.replace(rule.conditionValue,rule.actionValue)
console.log(nval)
r.setValue(rowData[column] = nval)
break;
default:
r.setValue(rowData[column] = rule.actionValue);
}
case "replace":
const val=rowData[column];
const nval=val.replace(rule.conditionValue,rule.actionValue);
console.log(nval)
r.setValue(rowData[column] = nval);
break;
// yap(`${rule.actionColumn}[${rowNum}]="${rule.actionValue}"`);
// if (rule.comparison == "match regex") {
// rule.actionColumn.replace(rule.comparison,rule.actionValue)
// r.setValue(rowData[column] = rule.actionColumn)
// }
// else {
// r.setValue(rowData[column] = rule.actionValue);
// }
break;
Probably not optimal use of the data structures defined in the code, but I’ve yet to tease out the design.