text matching help

Tim Williams listserver at tdw.net
Thu Sep 9 13:28:10 CEST 2004


[newbie still]

I have a dictionary with around 500 keys,    50 to 100 of those keys will be
in the format  *text  or text*  (eg  "*williams" or "tim*" )  for use as
wildcards.

I need to be able to match some input text  to these wildcards  (eg timothy
will match tim*),    * on its own is invalid,  there must be text before or
after the *.

I've never used Regular Expressions, and so can't judge whether they are
suitable (ie the best way)  for searching  MyDict.keys() to match the input
text and get the key's value,  or whether iterating the keys and using
startwith()  or endswith() would be better.     Or (probably) there is a
different and  much better way of doing it.

Any advice would be gratefully received.

TIA

Tim






More information about the Python-list mailing list