I am re-asking the question posted by meaydemi at Left priority in dropdown search. My dropdown search labels include ~5000 stock ticker symbols. When I type M (or any letter that isn’t A), I want to see the stocks beginning with M before the dozens or hundreds of single ticker symbols that have an M inside it.
Is there any way to do a left-priority search, and if not, I’d really think that is a critical option to add without too much difficulty. I can see the benefit of finding pattern matches in the center of the string if that’s all you find, but those should be placed behind front matches.
A second thing I’ve noticed is that the search seems to be ignoring spaces. In this case if I typed "SYM " (SYM being hypothetical for anything) it would match all strings with SYM inside (space or not) and not isolate the label that is “SYM - Corporation Name”. If there is any way to make this work properly now, or in the future that would be helpful.
return [o for o in options if re.match(search_value, o[“label”], re.IGNORECASE)]
for front matches only or:
opt = [o for o in options if re.match(search_value, o[“label”], re.IGNORECASE)]
opt.extend([o for o in options if o not in opt and search_value in o[“label”]])
return opt
hi marketemp,
I’m interested in the same topic, I used your solution but the error message ask about the ‘re’ you are using.
Is there any component that is needed to import as ‘re’?
Thanks!
and to have the right ticker come up even when you type the full company name. As you can see in my example, I definitely have the Ticker->Name mapping done using another dict but even when my update would return TSLA when typing Tes as indicated within my print examples, something within dash filters it beyond that and TSLA is not an option in the dropdown.