Hi, im using string.replaceAll() to get rid of a load of random text from a file, however i keep getting the exception java.util.regex.PatternSyntaxException: Illegal repetition( and where its all gone wrong)
I think its because it doesnt like me doing the 'cleanString = cleanString' bit, can I put all the expressions into 1? The only other way i can think is to have loads of variables and that would just suck.
for(;;)
{
while (loopCount<=84)
{
String testString = reader.readLine();
if (testString.equalsIgnoreCase(""))
{
testString = reader.readLine();
}
cleanString = testString.replaceAll("@", "");
cleanString = cleanString.replaceAll("{", "");
cleanString = cleanString.replaceAll("}", "");
cleanString = cleanString.replaceAll("=", "");
tokenizeThis = new StringTokenizer(cleanString);
word = tokenizeThis.nextToken();
if (word.equalsIgnoreCase("name"))
{
cleanString = cleanString.replaceAll("name", "");
cleanString = cleanString.replaceAll(" ", "");
captainList[loopCount] = cleanString;
loopCount++;
System.out.println("Captain " + cleanString);
}
else
{
playerList[loopCount][loopCount2] = cleanString;
loopCount2++;
System.out.println("Player " + cleanString);
if (loopCount2>=6)
{
loopCount2 = 0;
}
}
}
}
A section of the file im trying to read:
@ {
name = "john jackson",
steve smith],
thomas adams],
}
Hope you can help, been working on this for a while, thank you very much in advance!