Increment a string with both letters and numbers

前端 未结 8 1851
故里飘歌
故里飘歌 2020-12-19 00:50

I have a string which i need to increment by 1 The string has both characters and numeric values.

The string layout i have is as follows \"MD00494\"

How woul

8条回答
  •  难免孤独
    2020-12-19 01:16

    You can use regex:

    int kod = int.Parse(Regex.Replace(sdesptchNo, "[^0-9]", "")) + 1;
    
    string zeroStr=Regex.Replace(sdesptchNo, "[^0-9]", "");
    string newZeroStr="";
    for (int x=0;x

    UPDATED: This will save your zero

提交回复
热议问题