My dt contains words like
chocolates
biscuits
ice cream
i get the string from as input (lets say strCustomerInput)
I need to check if strCustomerInput.contains(dt words) if yes i need to fetch which word from strCustomerInput contained the word from dt(lets say strMatchedWord) ,take that strMatchedWord and check if strMatchedWord is present in dt
How can i do this in linq .
dt_Badword.AsEnumerable().Any(Function(row) Str_message.ToLower.Contains(row.Field(Of String)(0).ToLower)) - this gives if strCustomerInput.contains(dt words)
if my input text strCustomerInput = I work in Candyland"
dt is
chocolate
ice cream
Candy
this becomes true as Candyland contains candy.
so thought of logic
step 1 -check strCustomerInput contains dt if yes take the word that go matched from strCustomerInput and proceed to step 2
step 2 -keep the word that got matched in this case it is Candyland check in dt whether Candyland is present in dt .
lets assume my dt contains ice cream and if str =“i want ice in my coke” it becomes true as ice is there .i want this to be false.i want exact match from dt .it works for single words in dt but doest work for multiple word though.
It would be false…as per the above code…because it searches for full ice cream in the given string…and not bits like ice or cream
The given formula above check if the value in dt is matchign with str and not viceversa and it is checking for full string that is present in dt and not partial
dt.AsEnumerable.Where(function(x) System.Text.RegularExpressions.Regex.IsMatch(str.ToLower,"\b" + x(0).ToString.Trim.ToLower + "\b"))(0) to get the matched string
Assuming only one will match…if multiple then can get all as well