Detect HTML links

  • + 0 comments

    Only Regex solution, no string modification except trim (which is given)

    const regex = <a .*?href="(.*?)".*?>([^<].*?)<.*?; const parseAll = new RegExp(regex, "g");
    const parseInv = new RegExp(regex); input.match(parseAll).forEach((str) => { const res = parseInv.exec(str); console.log(res[1] + "," + res[2].trim()); });