±Û¾´ÀÌ :À̽¹è 2000³â 2¿ù 14ÀÏ 18:05:08
In Reply to: [Áú¹®]¹®ÀÚ¿ ġȯÀº ¾î¶»°Ô Çմϱî? posted by Kim-jinwoo on 2000³â 2¿ù 14ÀÏ 15:21:37:
¼Ò½º¸¦ ÷ºÎÇÕ´Ï´Ù.
//ÀÌ ¸Þ¼Òµå´Â ¹®ÀÚ¿ ³»ÀÇ Æ¯Á¤ ¹®ÀÚ¿À» ġȯÇÒ¶§ ¾²ÀδÙ
//source: ¿øº» ¹®ÀÚ¿
//oldStr: ¿øº» ¹®ÀÚ¿Áß ¹Ù²Ü ¹®ÀÚ¿
//newStr: ´ëÄ¡µÇ´Â ¹®ÀÚ¿
public static String castString(String source, String oldStr, String newStr)
{
String temp;
String destString = "";
int pos = 0;
while((pos = source.indexOf(oldStr)) != -1)
{
temp = source.substring(0, pos);
source = source.substring(pos + oldStr.length(), source.length());
destString = destString + temp + newStr;
}
destString = destString + source;
return destString;
}