I'm looking for a Visual Studio Code / JavaScript regex for an XML file since it contains many key words that need to be changed for to clone for another application. This is for a few files so it will be a very useful regex for us. This is what I've managed to use but it doesn't capture everything:
<script>(?=(?:(?!<\/?script>).)*?'\bincident\b').+\n.*?<\/script>
What we're trying to capture is the beginning script tag, the ending script tag, and pointing out any words that contain the word 'Incident' so that we can replace it with another word.
<script><![CDATA[(function executeRule(current, previous) {
var incidentSysId = current.sys_id;
var incDisplayValue = current.getDisplayValue();
var incTaskGrDefault = new GlideRecord("incident_task");
incTaskGrDefault.newRecord();
var taskStateUtil = new TaskStateUtil(incTaskGrDefault);
var INACTIVE_STATES = taskStateUtil.getInactiveStates() || taskStateUtil.SYSTEM_INACTIVE_STATES;
var incTaskGr = new GlideRecord("incident_task");
incTaskGr.addActiveQuery();
incTaskGr.addQuery("x_g_cd3_learning_lms_incident", incidentSysId);
incTaskGr.addQuery("state", "NOT IN", INACTIVE_STATES);
incTaskGr.query();
if(current.state == IncidentState.CLOSED)
closeOpenIncidentTasks();
else if(current.state == IncidentState.CANCELED)
cancelOpenIncidentTasks();
function closeOpenIncidentTasks() {
var CLOSED_INCOMPLETE_STATE = 4;
while(incTaskGr.next()) {
incTaskGr.work_notes = gs.getMessage("Incident Task is Closed Incomplete based on closure of {0}.", incDisplayValue);
incTaskGr.setValue("state", CLOSED_INCOMPLETE_STATE);
incTaskGr.update();
}
}
function cancelOpenIncidentTasks() {
var CLOSED_SKIPPED_STATE = 7;
while(incTaskGr.next()) {
incTaskGr.work_notes = gs.getMessage("Incident Task is Closed Skipped based on cancelation of {0}.", incDisplayValue);
incTaskGr.setValue("state", CLOSED_SKIPPED_STATE);
incTaskGr.update();
}
}
})(current, previous);]]></script>
Thank you very much!