Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
How to Count Occurrences of a Word in a String (LINQ) (C#)
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { var text = "Hello world! asdf asdffdfsdfsf asdf"; var word = "asd"; var count = text.ToLowerInvariant().Split(new string[]{word.ToLowerInvariant()}, StringSplitOptions.None).Count() - 1; //Your code goes here Console.WriteLine(count); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Caelum
GetEnumerator
Easy prgm
Get year quarter from date
edmond@DESKTOP-M2BC2LH
qwerty
Array value changer?
if Two Words Are Anagrams of Each Other
Prime Number
puzzle piezas
Please log in to post a comment.