From a8f2e6d7cf50a021d849314889318d22b0818cc4 Mon Sep 17 00:00:00 2001 From: alordash Date: Sun, 22 Aug 2021 01:08:22 +0300 Subject: [PATCH] Changed cycle --- lib/regex-extractor.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/regex-extractor.js b/lib/regex-extractor.js index 3061775..f861473 100644 --- a/lib/regex-extractor.js +++ b/lib/regex-extractor.js @@ -10,8 +10,7 @@ const { distance } = require('@alordash/damerau-levenshtein'); function extractRegexChars(words, errorLimit = 1) { let expressions = []; const parsingRules = LoadExpressions(); - let k = words.length; - while (k--) { + for (let k = 0; k < words.length; k++) { let word = words[k].text; let match = word.match(/[,.;:!?]/); if (match != null && (match.index + match[0].length == word.length)) { @@ -45,7 +44,7 @@ function extractRegexChars(words, errorLimit = 1) { if (!found) { expression = new Expression(words[k].text, '.', 0, 0, 0, undefined, words[k]); } - expressions[k] = expression; + expressions.push(expression); } return expressions; }