Last active
June 18, 2026 13:31
-
-
Save refringe/287021e530884d2650c94e18deac0eb2 to your computer and use it in GitHub Desktop.
Parse a Markdown link and capture the masked and actual parts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text.RegularExpressions; | |
| public partial class MarkdownParser | |
| { | |
| [GeneratedRegex(@"\[(?<masked>[^\]]+)\]\((?<actual>[^)]+)\)")] | |
| private static partial Regex MarkdownLinkRegex(); | |
| public void ParseLinks(string input) | |
| { | |
| foreach (Match match in MarkdownLinkRegex().Matches(input)) | |
| { | |
| string masked = match.Groups["masked"].Value; | |
| string actual = match.Groups["actual"].Value; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment