c# - Match all words in any order -
how match search string every word using linq? i.e. "apple orange" should match on "orange apple" not "apple orange fred".
this query here works find if single word matches, not work all() words matching.
var match = "apple orange pear".split() .intersect("orange pear fred".split()) .any();
the idea similar thread. word-wise super string search given string
check if each word exists in check list:
var words = "orange pear fred".split(); var wordstocheck = "apple orange".split(); var match = words.all(w => wordstocheck.contains(w));
or produce difference of 2 sequences. if there no elements in difference, words in check list:
var match = !words.except(wordstocheck).any();
Comments
Post a Comment