Given a set of words, I need to know which words are formed only by a set of letters. This word can not have more letters than allowed, even if this letter is part of the verification set.
Example:
Char set: a, a, ã, c, e, l, m, m, m, o, o, o, o, t (fixed set)
Words set: mom, ace, to, toooo, ten, all, aaa (variable set)
Result:
mom = true
ace = true
to = true
toooo = true
ten = false (n is not in the set)
all = false (there is only 1 L in the set)
aaa = false (theres is only 2 A in the set)
How to generate this regular expression in Javascript? (Case sensitive is not a problem).
I have tried this code without success:
var str = "ten"
var patt = new RegExp("^[a, a, ã, c, e, l, m, m, m, o, o, o, o, t]*");
console.log(patt.test(str));