using System.Text.RegularExpressions;
using System.Collections.Generic;
string inputString = " This is a sample string with multiple spaces. ";
List<string> result = ParseWords(inputString);
foreach (string word in result)
static List<string> ParseWords(string input)
string pattern = @"\b\w+\b";
Regex regex = new Regex(pattern);
MatchCollection matches = regex.Matches(input);
List<string> words = new List<string>();
foreach (Match match in matches)