Well, as the title says... I want to grab a certain word that is hashtagged in a string.
Example: This is a string that #contains a hashtag!
I want to pick out the word contains from the string as a new string.
I can imagine that this is a very simple problem, but I really can't get it to work.
How good do you want this pattern to be? In theory just:
"(?<=#)\w+"
would do it.
Edit, for more answer completeness:
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With