How to replace part of string by position?

后端 未结 18 918
逝去的感伤
逝去的感伤 2020-11-28 04:37

I have this string: ABCDEFGHIJ

I need to replace from position 4 to position 5 with the string ZX

It will look like this: ABC

18条回答
  •  猫巷女王i
    2020-11-28 05:32

    It's better to use the String.substr().

    Like this:

    ReplString = GivenStr.substr(0, PostostarRelStr)
               + GivenStr(PostostarRelStr, ReplString.lenght());
    

提交回复
热议问题