const regex = new RegExp('[a-z0-9 %\\-\\+:\\/]*\\b(\\d{1,3}\\.?\\d{0,4})\\.?[a-z0-9 \\(\\)]*out of[a-z ]*(\\d{1,3}\\.?\\d{0,4})\\.?.*', 'gm')
const str = `4 out of 6.0
2.979 out of 4 gpa
out of 5
gpa 3.712 out of 4
110 out of 110
4.94 (for second part) out of 6
9.45 points out of 10 (240 ects)
5.7 out of 7.
cgpa- 3.66 out of 4
a-/gpa :3.55 out of 4.00
4.5 out of a possible 5
a4 19 out of 22
1.15 1 being the best grade out of 5
3.64out of 6
28 out of 30. final grade 108 out of 110
2.64out of 4 average 74.02%
81.77. gpa:3.7out of 4.3
81.77gpa:3.7 out of 1.3
cumulative gpa 16.22out of 20.00
9.13 rank 20 out of 80
a+/9.65 out of 10
3.6/4 or 17.87 out of 20
87.1%/gpa 3.71 out of 5.0`;
// 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