From 45ed410474a4bd0aef57bf43fda9837d61c222df Mon Sep 17 00:00:00 2001 From: Adrien NUNES <anunes.etudiant@gmail.com> Date: Fri, 24 Nov 2023 03:43:30 +0100 Subject: [PATCH] Fix --- database/RandomSentence.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/database/RandomSentence.js b/database/RandomSentence.js index 5ef7d4c..0fb2b49 100644 --- a/database/RandomSentence.js +++ b/database/RandomSentence.js @@ -11,6 +11,7 @@ const actionRE = new RegExp('<action>', 'gi'); const MAX_ITERATIONS = 10; function fillAllRandomObject(sentence, regularExpr, category){ + const matches = sentence.matchAll(regularExpr); let objectString = ""; let newSentence = sentence; @@ -23,12 +24,11 @@ function fillAllRandomObject(sentence, regularExpr, category){ } function shouldBeFilled(sentence) { + return [actorRE, reasonRE, sourceRE, actionRE].some((re) =>{ - const b = re.test(sentence) - if(b){ - const matches = sentence.matchAll(re); - for(let match of matches) console.log(match); - } + const result = re.test(sentence) + re.lastIndex = 0; + return result; }); } -- GitLab