i need to find all links in html string only in href on both cases of double qute("") or single qute('')
example:
<a href='text'>
or
<div href="text">;
i came up with
function findHrefValues(str) {
let hrefs = [];
let pattern = /href='([^']+)'/g;
let match = pattern.exec(str);
if(match && Array.isArray(match)) {
match.forEach((href)=> {
if(href) hrefs.push(href);
});
}
return hrefs;
}
but its not working well it doesn't recognize double qute.