How to extract URL from email body using JavaScript and Regex?
I am posting this for the third time because for the last two times, I had an issue with getting the right Regex (ECMAScript) for the URL that I was trying to convert (from email body), but it appears that this Regex should be good one as I verified with Regex101.
I have Logic App that looks like bottom:
I am trying to get part of email text like below:
originalsrc="https://portal.carefeed.com/xxxxx/reports/report/emailReport?details=60a286e8-d616-452c-87a5-65ccff6f01cb"
Why do I get "InvalidCodeScriptRunTimeFailure"?
Bottom is JavaScript that I was using on the third process (Execute JavaScript Code).
const jsonString = workflowContext.trigger.outputs.body.bodyPreview;
const jsonObject = JSON.parse(JSON.stringify(jsonString))
const regex = /originalsrc=\\"https:\/\/(www\.)?\w+(\.\w+).*$"/;
const match = jsonObject.match(regex);
if (match) {
return "Matched"
} else {
return "No Match"
}
Bottom are two posts that I asked:
And this is article that I got some clue to start with:
Thank you.