I need to use RegEx.Replace to replace only certain named groups in my input string.
So I might have a pattern like:
"^(?<NoReplace>.+)(?<FirstPeriod>(\d{2})|CM|RM|PM|CN|RN){1}(?<LastPeriod>(\d{2})|CM|RM|PM|CN|RN){1}((#(?<NumberFormat>[#,\.\+\-%0]+))*)$"
Tokens such as CM, RM are being replaced using Regex.Replace with a MatchEvaluator. However, this should only be replacing characters in the FirstPeriod and LastPeriod groups.
Example input: "FIELDCNS 01CM"
Desired output: "FIELDCNS 0104"
Incorrect output: "FIELD**04**S 0104"
Is this possible or am I best just pulling out the parts I want to replace and re-assembling afterwards?
thanks