existence of $ in test should be checked with indexOf >= 0 instead of indexOf > 0

master
melvin 2012-11-19 22:18:54 +08:00
parent 04c4dbfa95
commit 5964a51cd5
1 changed files with 1 additions and 1 deletions

View File

@ -70,7 +70,7 @@ public class MagicMessage {
public static String replaceChoices(final String sourceText,final Object[] choices) {
String result = sourceText;
for (int idx = 0; result.indexOf('$') > 0; idx++) {
for (int idx = 0; result.indexOf('$') >= 0; idx++) {
final String choice = (idx < choices.length && choices[idx] != null) ? choices[idx].toString() : "";
final String replacement = (!choice.isEmpty()) ? " (" + choice + ")" : "";
result = result.replaceFirst("\\$", replacement);