Java

StringBuilder 용 replace 함수

풍풍 2015. 8. 19. 18:10

public void replace(StringBuilder builder, String from, String to)

{

   int index = builder.indexOf(from);

   while (index != -1)

   {

       builder.replace(index, index + from.length(), to);

       index += to.length(); // Move to the end of the replacement

       index = builder.indexOf(from, index);

   }

}


출처: http://stackoverflow.com/questions/3472663/replace-all-occurences-of-a-string-using-stringbuilder