_String Replace (for real)
Replaces all occurances of a given substring with another substring in a String object. I looked for a good string replacer and all of them broke (replaced things multiple times, infinitely looped, etc), so I made one. Please let me know if this doesn't work, because if it doesn't work for you then it doesn't work for me! Thanks.
AI
AIサマリー: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
ソースコード
public static String replaceString(String aSearch, String aFind, String aReplace)
{
String result = aSearch;
if (result != null && result.length() > 0)
{
int a = 0;
int b = 0;
while (true)
{
a = result.indexOf(aFind, b);
if (a != -1)
{
result = result.substring(0, a) + aReplace + result.substring(a + aFind.length());
b = a + aReplace.length();
}
else
break;
}
}
return result;
}
Upload
オリジナルのコメント (3)
Wayback Machineから復元