Given this (TeX) string (with a newline at the end): \fill[cardbackground, rounded corners=2pt] (0,0) rectangle (\cardwidth,\cardheight);
I am able to match with this regex: ~r/.*(cardbackground).*;\n/
How do I replace only the first group match (which is cardbackground in this case) using something like: Regex.replace(~r/.*(cardbackground).*;\n/, source, "{RGB}{245,245,245}")
Reason for changing only a single group within a match is:
There might be a small chance that cardbackground can appear within another context more than one time and matching just this is not enough.
But I will be able to match the surrounding text using one or two lookaheads