How I can find in ETS table by a string that ignore upper/lower case?
This code find by a string starting with wo:
ets:test_ms({"WORD"}, [{{"wo"++'_'}, [], ['$_']}])
But, like WORD is upper case, nothing is returned.
Thanks!
How I can find in ETS table by a string that ignore upper/lower case?
This code find by a string starting with wo:
ets:test_ms({"WORD"}, [{{"wo"++'_'}, [], ['$_']}])
But, like WORD is upper case, nothing is returned.
Thanks!
There is not a support for the case-insensitive matching in match spec (or matching in Erlang generally). You have basically three options there.
Generate all cases
[{{"wo"++'_'}, [], ['$_']}, {{"wO"++'_'}, [], ['$_']}, {{"Wo"++'_'}, [], ['$_']}, {{"WO"++'_'}, [], ['$_']}]
Use guard expression (for longer words because the number of combinations is 2^N)
[{{['$1','$2'|'_']},
[{'orelse',{'=:=','$1',$w},{'=:=','$1',$W}},
{'orelse',{'=:=','$2',$o},{'=:=','$2',$O}}],
['$_']}]
Transform data in ets table using string:casefold/1 and search by this key.