Fix more bugs related to replacing

Also some involving parentheses
This commit is contained in:
DominikDoom
2023-04-23 19:58:49 +02:00
parent 38fd2523e6
commit 84b6a0394e
2 changed files with 67 additions and 53 deletions

View File

@@ -90,12 +90,12 @@ function difference(a, b) {
}
// Sliding window function to get possible combination groups of an array
function toWindows(inputArray, size) {
function toNgrams(inputArray, size) {
return Array.from(
{length: inputArray.length - (size - 1)}, //get the appropriate length
(_, index) => inputArray.slice(index, index+size) //create the windows
)
}
{ length: inputArray.length - (size - 1) }, //get the appropriate length
(_, index) => inputArray.slice(index, index + size) //create the windows
);
}
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string