Skip to content

Instantly share code, notes, and snippets.

@xivol
Created April 16, 2025 20:05
Show Gist options
  • Select an option

  • Save xivol/385f246906dde7d23438b7121b28851d to your computer and use it in GitHub Desktop.

Select an option

Save xivol/385f246906dde7d23438b7121b28851d to your computer and use it in GitHub Desktop.
hashtags
public static List<string> ExtractHashtags(string postContent)
{
var regex = new Regex(@"#\w+");
return regex.Matches(postContent)
.Cast<Match>()
.Select(m => m.Value.TrimStart('#'))
.Distinct()
.ToList();
}
public string ContentWithLinks
{
get
{
return Regex.Replace(Content, @"#(\w+)",
"<a href='/Ponds/Posts/$1'>#$1</a>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment