How good is this template? Theoretically true:
"(?<=#)\w+"
will do it.
Edit, for greater completeness, answer:
string text = "This is a string that #contains a hashtag!"; var regex = new Regex(@"(?<=#)\w+"); var matches = regex.Matches(text); foreach(Match m in matches) { Console.WriteLine(m.Value); }
source share