RegEx to extract link (a) with href only

string pattern = @"(<a.*?(?<href>href=\x22.*?\x22).*?>)";
string substitution = "<a ${href}>";
RegexOptions options = RegexOptions.Multiline;

Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);

Additional information for Substitutions in Regular Expressions

Comments

Leave a Comment

All fields are required. Your email address will not be published.