forum

Home / DeveloperSection / Forums / C# regular expression to get words between 4 to 10 characters

C# regular expression to get words between 4 to 10 characters

Takeshi Okada 2088 30-Jan-2014

I am trying to get all the words in a string, that are at least 4 characters long and less than 10 characters. When I use the following regular expression, it just returned the whole string as one word. Can you please look at the following example and tell me how should I write this regular expression?

string result = "Overfishing, erosion and warmer waters are feeding jellyfish blooms in coastal regions worldwide. And they're causing damage"

string[] words = Regex.Split(result, @"[\W]{4,10}");

foreach (string line in words)

{

    Console.WriteLine(line);

}


c# c# 
Updated on 30-Jan-2014

Can you answer this question?


Answer

1 Answers

Liked By