it works and this is how the method looks. I use strings for everything now, just convert the numbers to string before i use this method. I found out that using the %s notation is best after all, if I were to use [var] then it could be mixed up with someting where you actually WANT to type [10] and not the value itself. %s is never used in any sentences that make sense so better use them.
public static String replaceAll(String s, String[] var)
{
for(int i=0;i<var.length;i++)
{
String next = "%s" +(i+1) ;
s=s.replaceAll(next, var [ i ] );
}
return s;
}
Token order *does* change when localising text, so your mechanism is fundamentally flawed to begin with.
Also assuming the tokeniser special character will never be required is a poor limitation - you would normally allow escaping of the token identifier character to circumvent this limitation.
e.g. the String "%%" in the input String is substituted with the String "%" in the output.
As oNyx has pointed out - If you are using J2SE, all this functionality is provided for you already - why reinvent a substandard wheel, when a very good one has already been provided?
If this is for J2ME, then it is still a valid problem.