Replace text in StringBuilder via regex

后端 未结 6 872
旧时难觅i
旧时难觅i 2021-01-19 01:33

I would like to replace some texts in StringBuilder. How to do this?

In this code I got java.lang.StringIndexOutOfBoundsException at line with mat

6条回答
  •  轮回少年
    2021-01-19 02:08

    Lets have a StringBuilder w/ 50 total length and you change the first 20chars to 'x'. So the StringBuilder is shrunk by 19, right - however the initial input pattern.matcher(sb) is not altered, so in the end StringIndexOutOfBoundsException.

提交回复
热议问题