Hey @King Java
I used an AI assistant to generate some code that will return the href of the anchor tag where the link text matches your last URL. I think that's probably the best way; but this code will fail should that inner text ever change.
function getHrefFromAnchorTag(htmlString) {
const regex = /<a\s+[^>]*href="([^"]*)"[^>]*>View Admissions\/Readmissions Report Results<\/a>/i;
const match = htmlString.match(regex);
let result = null;
if (match && match[1]) {
result = match[1];
}
return result;
}
// Example usage:
const htmlString = '<a href="someurl">View Admissions/Readmissions Report Results</a>';
const result = getHrefFromAnchorTag(htmlString);
console.log(result); // Output: "someurl"
This code is untested but hopefully will get you pointed in the right direction. In my opinion, you don't need to strip out the safelinks.outlook.com part of the url.
If you know for certain that the link you need will always be the last one, then you can update the above snippet to match any anchor tag and take the last match.