- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2022 09:17 PM
Hello Experts,
I need help with getting the output of Regex in Flow Designer.
I am using Regex to get contents from email body, when I am testing the Regex in Regex101, I am getting the results I want, but every time when I am using it in flow designer I am unable to get output for index 1, below is the text from email,
########################################################################################
contingency outage:
Interruption Start
Interruption Finish
Duration
Initial outage
Saturday 20 August 2022 21:00 (AEST)
Sunday 21 August 2022 11:00 (AEST)
14 hours 0 minutes
Contingency outage
Sunday 21 August 2022 11:00 (AEST)
Sunday 21 August 2022 12:00 (AEST)
1 hours 0 minutes
Outage duration
Saturday 20 August 2022 21:00 (AEST)
Sunday 21 August 2022 12:00 (AEST)
15 hours 0 minutes
##################################################################################
I am trying to get the output of everything after Outage duration using the below Regex
/Outage duration(?:\s)(.*)(?:\s)(.*)(?:\s)(.*)/gm
The output in Regex101 shows I am able to capture all what I want in Index 1, 2 and 3.
I am using the following script in Flow designer to get the results from email
(function execute(inputs, outputs) {
var rspOutageExpression = new RegExp(/Outage duration(?:\s)(.*)(?:\s)(.*)(?:\s)(.*)/gm);
var keywords = {rspOutageDetails: "Outage duration"};
// Grab Outage Timings that were communicated to RSP's under the TimeFrame Table
var rspStart_Outage = "";
var rspEnd_Outage = "";
var rspTotal_Time = "";
/* #################################################################################################################################### */
var matchRSPStartOutageChk = rspOutageExpression.exec(inputs.email);
if(!JSUtil.nil(matchRSPStartOutageChk)){
rspStart_Outage = matchRSPStartOutageChk[1].toString(keywords.rspOutageDetails.length).trim();
}
var matchRSPEndOutageChk = rspOutageExpression.exec(inputs.email);
if(!JSUtil.nil(matchRSPEndOutageChk)){
rspEnd_Outage = matchRSPEndOutageChk[2].toString(keywords.rspOutageDetails.length).trim();
}
var matchRSPTotalTimeChk = rspOutageExpression.exec(inputs.email);
if(!JSUtil.nil(matchRSPTotalTimeChk)){
rspTotal_Time = matchRSPTotalTimeChk[3].toString(keywords.rspOutageDetails.length).trim();
}
/* #################################################################################################################################### */
outputs.rsp_start_outage = rspStart_Outage;
outputs.rsp_end_outage = rspEnd_Outage;
outputs.rsp_total_outage_time = rspTotal_Time;
})(inputs, outputs);
But when I am running the flow I am not getting the value for rsp_end_outage in outputs, and no matter what I do it just comes as blank. Below is the output of the flow
I would really appreciate if someone can please solve this mystery?
Regards.
Nasir
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2022 01:54 AM
found the solution by not using global and multiline switch
var rspOutageExpression = new RegExp(/Outage duration(?:\s)(.*)(?:\s)(.*)(?:\s)(.*)/);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2022 01:54 AM
found the solution by not using global and multiline switch
var rspOutageExpression = new RegExp(/Outage duration(?:\s)(.*)(?:\s)(.*)(?:\s)(.*)/);