You must first find out some commonality between the lines. If at the end there is always a prefix of letters followed by numbers (with a fixed width), you can simply delete the letters, analyze the rest, increment and reconnect them.
eg. in your case, you can use something like the following:
var prefix = Regex.Match(sdesptchNo, "^\\D+").Value; var number = Regex.Replace(sdesptchNo, "^\\D+", ""); var i = int.Parse(number) + 1; var newString = prefix + i.ToString(new string('0', number.Length));
Another option that might be a little more reliable might be
var newString = Regex.Replace(x, "\\d+", m => (int.Parse(m.Value) + 1).ToString(new string('0', m.Value.Length)));
This will replace any number in the string with an incremental number of the same width, but leaves all the odd numbers exactly the same and in the same place.
source share