My example code:
public static bool StringSearchHit(string keyWord, params string[] targetArray)
{
foreach (string targetItem in targetArray)
{
if (targetItem.IndexOf(keyWord, StringComparison.InvariantCultureIgnoreCase) >= 0)
return true;
}
return false;
}
The problem I have: the LIKE
operator in SQL is not just string.Contain()
or string.IndexOf()
, there are "culture character similarity" in it (I don't know how to call it).
Example: when I search using LIKE '%pokemon%'
, the "Pokémon" will also be included. The character "é" will be considered as similar to "e".
Same for some German characters. The special characters "ä ö ü" will also be considered "like" "a o u" in SQL.
My goal: when the keyWord
is "aou", and one of the targetArray
has "äöü", it will also return true
.
Is there any equivalent of this in c#?
Edit: thanks for pointing out about another post:
Ignoring accented letters in string comparison
That is the correct direction, but in another issue, it's "compare", not "contain". How to do similar thing in "string.Contain"?
Edit 2: Thanks for the correct answer:
Complex "Contains" string comparison
Tried this solution, "Pokémon" can be searched using "Pokemon", and "Æon Flux" can be searched using "aeon".
Case close and marked as duplicate.