c# - Can LINQ be used to pull keywords out of a string? -
if have long-ish string of text , wanted pull out words greater 4 characters in length , found more 4 times in string, can linq that?
you may able tighten up, believe effect of
var results = inputstring.split() .where(word => word.length > 4) .groupby(word => word) .where(grp => grp.count() > 4) .select(grp => grp.key);
you will, of course, need decide how wish deal punctuation might present.
so given input
var inputstring = @"the quick brown fox jumped on lazy dog quick brown fox jumped on lazy dog quick fox jumped on lazy dog quick fox jumped on lazy dog quick brown fox jumped on lazy dog";
the results contain "quick" , "jumped" because other word greater 4 characters ("brown") appeared 3 times.
Comments
Post a Comment