.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 asp.NET blah asp.NET blah asp.NET bli asp.NET bli bli ASP.NET Blue ASP.Net yop yop ASP

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;

  • Record 2
  • Record 2
  • LinqToSQL is best, but LinqToObject should also be: )

    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

    Popular posts from this blog

    asp.net - Javascript/DOM Why is does my form not support submit()? -

    sockets - Delphi: TTcpServer, connection reset when reading -

    javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -