const regex = /([^%>\s]+)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('([^%>\\s]+)', 'g')
const str = `51.23%
17.84%
72.31%
59.31%
64.48%
0.19%
1.13%
0.00%
0.00%
32.18%
0.00%
11.68%
35.60%
10.36%
0.00%
50.99%
84.03%
2.96%
47.17%
57.53%
> 90%
64.49%
59.04%
85.09%
74.25%
0.00%
0.00%
85.00%
16.13%
35.09%
12.14%
0.00%
54.82%
86.50%
0.00%
77.30%
0.15%
46.89%
89.56%
34.88%
0.00%
4.66%
0.00%
0.00%
0.00%
24.49%
28.44%
0.00%
0.00%
2.17%
41.77%
11.59%
0.00%
26.14%
0.90%
> 90%
73.00%
15.18%
0.00%
0.00%
7.41%
> 90%
> 90%
63.89%
89.58%
75.06%
85.52%
59.10%
38.19%
44.98%
83.05%
35.33%
62.60%
> 90%
> 90%
15.05%
0.00%
> 90%
15.21%
0.00%
7.26%
0.00%
0.00%`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// 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