Let's say I have these items in a list full of strings:
- Cash
- Cheque
- Postal Order
- Credit Card
- Bank Transfer
- etc... etc... etc...
I found a nice thing called "LevenshteinDistance". This is working up to some point. It does not always return the correct string if I type something wrong.
I am thinking of going to the Regex side to get this.
Basically I want to type, for example, "chq" and it should return "Cheque".
I have this code to try this but it is also not working correctly:
foreach (string entry in lsbSuppliedData.Items)
{
entr = entry.Trim().Replace(" ", "");
regex = new Regex("^[" + inputString + "]+$", RegexOptions.IgnoreCase);
if (regex.IsMatch(inputString))
{
proposal = entry;
//break;
}
}
Can someone please just help me into the right direction? I have a list with the items it should suggest, which at max would be 20 items (not very big, so performance is not a big issue).