Regex.Matches with two variables

Apr 25 2013 6:39 AM

Hello,

i have a problem with Regex.Matches.

We have following string:


string a = "BlaBlaBla (Link)->http://www.google.com id vel lorem.";


i want now to replace the string so that the output is


string b = "BlaBlaBla <a href="http://www.google.com">Link</a> id vel lorem";


I tried it since 3 hours with Regex.Matches but it don't work.


foreach (Match match in Regex.Matches(preview_text, "(([^)]*?))-([>]|[&][g][t][;])(http://[A-Za-z0-9$%/&;.-_ÜüÖöÄä?=]*)e"))
{
string part_1 = match.ToString();
string part_2 = match.Groups[1].Value;
string part_3 = ??;
}

so in part_1 should be "http://www.google.com" in part_2 should be "Link" and in part_3 should be "(Link)->http://www.google.com ".

Does somebody know how this could be realized in c#?


br,

kris




Answers (2)