check if the word consists of allowed characters before insert word in trie