JSFiddle - React, Tailwind, and code Playground

JavaScript

function pegarNumeros(string) {
  return string.match(/[0-9,\. ]+(?=\%)/);
}

alert(pegarNumeros('<p>Desconto 15.5%</p>'));
alert(pegarNumeros('<p>Desconto 15.5 %</p>'));
alert(pegarNumeros('<p>Desconto 15,5%</p>'));