I would like to replace certain text throughout an SVG file using regex.
For example, I might have many attributes like the following in the file:
<g clip-path="url(#clipId0)" fill="none" stroke="rgb(150,150,150)" stroke-opacity="0.14902" stroke-width="0.425" >
<polyline points="17001.1,7859.91 17018.7,7859.91 17018.7,7901.08 17001.1,7901.08 17001.1,7859.91 " />
<polyline points="17018.7,7880.5 17001.1,7880.5 " />
<polyline points="17018.7,7883.44 17001.1,7883.44 " />
</g>
and I would like to replace
stroke="rgb(150,150,150)"
to be
stroke="rgb(100,100,100)"
Note that the original numerical values will likely be different at each instance, but I want to change them all to (100,100,100)
I tried the following:
//Make SVG monochrome
string svgText = File.ReadAllText(svgPath);
Regex.Replace(svgText, "stroke=\"rgb(.*,.*,.*)\"", "stroke=\"rgb(100,100,100)\"");
File.WriteAllText(svgPath, svgText);
But of course, it did not work, because of the parenthesis. When I use an escape before the parens '\(' and '\)', I get the red squiggle error indicating an unrecognized escape character, but for regular expressions, I should escape parenthesis characters so that they are taken literally since they are special characters for regex. Correct?
How should I use regular expressions in this string to achieve what I want?