从User-Agent标头获取所有产品

如何从User-Agent标头中获取所有产品?

The syntax for User-Agent:

User-Agent: <product> / <product-version> <comment>

一个例子:

"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Safari Chrome/51.0.2704.103 Test (Something, Hi!)"

我已经尝试过使用正则表达式,并且看起来工作正常:

function getProductsFromUserAgent(userAgent) {
  const re = /(\w+)(?:\/\d+(?:\.\d+)*)?(?: \(.*?\))?/g;
  return [...userAgent.matchAll(re)].map((matched) => matched[1]);
}

const products = getProductsFromUserAgent(
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Safari Chrome/51.0.2704.103 Test (Something, Hi!)"
);

console.log(products);

有没有更好的方法而不使用正则表达式或更好的正则表达式呢?