convert list of strings to set of regexes; convert list of strings to trie

Klaus Neuner klaus_neuner82 at
Mon Jul 19 15:47:03 CEST 2004


I need a function that converts a list into a set of regexes. Like so:

  string_list = ["blaa", "blab", "raaa", "rabb"]

  print string_list2regexes(string_list)

This should return something like:

  ["bla(a|b)", "ra(aa|bb)"]

I am aware of the fact that converting the list to a *trie* would almost do
the job. But I couldn't find anything about Python modules that produce tries.

Are there any modules that I could use? Or do I have to implement it myself?


More information about the Python-list mailing list