Regex regex = new Regex(@"^(?<leftpart>[\d]?)/(?<rightpart>[\d]?)$", RegexOptions.Compiled | RegexOptions.IgnoreCase); Match m = regex.Match(yourString); if (m.Success) { string left = m.Groups["LeftPart"].Value; string right = m.Groups["RightPart"].Value; while (left.Length < 4) left.Insert(0, "0"); while (right.Length < 2) right.Insert(0, "0"); } else { // Handle error }
^(?<leftpart>[\d]+)(?<Symbols>[^\d]+)(?<rightpart>[\d]+)$
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)