const regex = new RegExp('(^|[+-]?\\d+\\.\\d*)$', '')
const str = `TICKER|LAST_UPDE|PX_LAST
EE0002M Index|20211231|-0.58814
US0002M Index||
USB3MAY Index|20220502|0.8x9
SOFRRATE Index|20220505|c0.79
FEDL01 Index|20220505|0.83
US0001M Index|2022050|0.84486
FDTR Index|20220505|1
US0003M Index|20220505|1.37071
PRIME Index|20220505|4
TICKER|LAST_UPDATE|PX_LAST
EE0002M Index|20211231|-0.58814
US0002M Index|20211231|0.1525
USB3MAY Index|20220502|0.89
PRIME Index|20220503|3.5
SOFRRATE Index|20220504|0.3
FEDL01 Index|20220504|0.33
US0001M Index|20220504|0.84514
FDTR Index|20220504|0.5
US0003M Index|20220504|1.40614
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions