How can I increase a product code by one?

Hello friends. I need your help. How can I increase a product code by one? This is of the form NOD00001. There are always five digits after NOD.

Example results: NOD00001, NOD00011, NOD00111.

we can do it eg. with regex replace

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

1 Like

when NOD00001 has to become NOD00002
then

  • extract with regex the numbers
  • conver and increase
  • leftpadding for filling up the numbers
1 Like

Sorry. I think I expressed myself wrongly. I want to increase by one but keep the same number of digits after NOD.

Examples: NOD00001, NOD00002…NOD00010, NOD00011, etc.

Hi,

The following expression will return incremental value in any digit “CCCCCNNNNN” format such as NOD00001 , XXXXXX01 or ABC123 etc.

System.Text.RegularExpressions.Regex.Replace(yourString,"\d+",Function(m) (Int64.Parse(m.Value)+1).ToString("D"+m.Value.Length.ToString))

Regards,

1 Like

Thanks a lot! It does exactly what I want.

1 Like

Thanks a lot!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.