Replace text in StringBuilder via regex

后端 未结 6 775
旧时难觅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:03

    I've solved this by adding matcher.reset():

        while (matcher.find())
        {
            sb.replace(matcher.start(), matcher.end(), "x");
            matcher.reset();
        }
    

提交回复
热议问题