JSFiddle - React, Tailwind, and code Playground

by brigand

JavaScript

const exclude = 'foo-baz';
const parts = [];

const chars = [...exclude];
for (const [i, c] of chars.entries()) {
	for (let j = 0; j < chars.length - i; j += 1) {
    const pre = chars.slice(0, i);
    const middle = chars.slice(i, i + j)
    const post = chars.slice(i + j + 1);

    const pattern = [
      ...pre,
      `[^${c}]`,
      ...post
    ].join('');
    parts.push(pattern);
  }
}

parts.push()