JSFiddle - React, Tailwind, and code Playground

by brigand

HTML

<pre id="out"></pre>

JavaScript

// ...or get a proper matchAll shim
function matchAll(string, regex) {
  const matches = [];
  string.replace(regex, (...args) => {
    matches.push(args);
    return '';
  })
  return matches;
}


const example = `This is a test CVE-2016-4346

https://security-tracker.debian.org/tracker/CVE-2016-4346

CVE-2016-4346 1234	

testing CVE-2016-4346
`;

const cves = matchAll(example, /(?:[^/])(cve-\d{4}-\d{4,7})/gi)
.map(match => match[1]);
out.textContent = cves.join('\n')