.net - Count word occurrences in a text field with LINQ -
How can I get a word event in a database text area with LINQ?
Keywords Token Sample: ASP.Net
4 Edit:
Database Records:
Record 1: [TextField] = " Blow blah blah blah bli bli as asp.NET blu asp.NET yop yop asp.NET
then
The event of 4 "ASP.Net" keywords in the record 1
In the record 2 of the keyword "ASP.Net" Two incidents are included
Record 3 includes 7 incidents of "ASP.Net" keyword
Collection extraction IList & lt;
NB: No problem about "." ASP.NET Keywords (if this is the question then this is not the goal)
A regex this well Handles you can use the \ b
metacharactor to anchor the word boundary, and avoid the keyword to avoid the unexpected use of special reggae characters. It also handles matters of the past, comma, etc.
string [] record = {"Fu ASP.Net Bar", "Foo Bar", "Foo ASP.Net" bar ASP.NET, "ASP.Net Foo ASP.Net. Bar ASP.NET "," ASP.Net, ASP.NET ASP.NET, ASP.NET "} string keyword =" ASP.Net "; string pattern = @" \ b "+ Regex. (Keyword) + @ "Quote = Records. Selection ((T, I) => New {index = I, Text = T, Calculation = Reges. Mats (T, Pattern). Content}). Orderbidescoding (item = & Gt; item.count); Foreach (query in var item) {Console.WriteLine ("Record {0}: {1} Events - {2}", Item Index, Item, Calculation, Item. Text);}
Waugh LA! :)
Comments
Post a Comment