diff --git a/src/addons/mod/lesson/services/lesson.ts b/src/addons/mod/lesson/services/lesson.ts
index 1d5a9ee78..c32b66b77 100644
--- a/src/addons/mod/lesson/services/lesson.ts
+++ b/src/addons/mod/lesson/services/lesson.ts
@@ -811,13 +811,13 @@ export class AddonModLessonProvider {
const matches = studentAnswer.match(new RegExp(expectedAnswer, 'g' + ignoreCase));
if (matches) {
isMatch = true;
- const nb = matches[0].length;
+ const nb = matches.length;
const original: string[] = [];
const marked: string[] = [];
for (let j = 0; j < nb; j++) {
- original.push(matches[0][j]);
- marked.push('' + matches[0][j] + '');
+ original.push(matches[j]);
+ marked.push('' + matches[j] + '');
}
for (let j = 0; j < original.length; j++) {