So what i've got is this simple method which should remove all characters except upper and lowercase letters and numbers from a string.
public static String toSimple(String arg) //redurziert einen String auf Buchstaben und ganze Zahlen
{
String string = arg;
int i = 0;
while ( i < string.length())
{
if (((int)string.charAt(i) >= 48 && (int)string.charAt(i) <= 57)||((int)string.charAt(i) >= 65 && (int)string.charAt(i) <= 90)||((int)string.charAt(i) >= 97 && (int)string.charAt(i) <= 121))
i+=1;
else
{
int a = string.length();
string = string.replaceAll(""+string.charAt(i), "");
if (!(string.length() < a)) //Just in case
{
i+=1;
}
}
The problem is that in some cases string.replaceAll
won't change anything though reached and given a character. I checked it in the debugger and couldn't find any apparent errors or exceptions. I didn't check the whole ASCII table, I know that the problem will occur for '$' '?' and '.'.
Any suggestions how to solve that?