How can I use the first group in Regex.Replace?
I've tried using $1
like the documentation said. Also it doesn't matter if I use grouping with ?:
or not...
string text = "<font color="#aa66bb">farbig</font>"
/// this does not work
Regex.Replace(text, "<font color="#(?:[\\d\\w]{6})">", "<font color=\"#$1\">");
// => "<font color=\"#$1\">farbig</font>"
// this works fine though
Regex.Match(text, "<font color="#([\\d\\w]{6})">").Groups[1];
// => aa66bb
So what am I doing wrong here?