I have only recently started using regex (.Net Framework) and in addition to this have started really trying to improve my C# knowledge. I'm currently trying to unpick another developers C# script as flaws have been identified with the output. Please consider the snippet of C# below, where 'CodeValue' is something like 'C300'.
string CodeValue = "C300";
Regex CodePattern = new Regex(@"(\d{1,3})/?([A-Z0-9]{1,2})?");
char padChar = '0';
Match m = CodePattern.Match(CodeValue);
ReturnString = m.Groups[1].Value.PadLeft(3, padChar)
+ (m.Groups[2].Success ? m.Groups[2].ToString() : "0")
+ "/"
;
Now, would I be correct in saying that this script will strip off the 'C' at the start of 'CodeValue' and then add an extra '0' at the end? Resulting in the variable 'ReturnString' being equal to 3000. I am almost certain I know what is going on here (thanks to google), but would like a little bit of clarification on what exactly is happening. e.g. what exactly is meant by the separate 'Groups[]'.
Any help would be appreciated, thanks.