I'm trying to parse through a string to get rid of garbage characters, in this example it's things like: &,%,$,#,*,@,etc. But I want to keep spaces and parentheses, right now I'm using a delimiter on a string and just building the string off of that:
public TokenIter(String line){
line.trim();
Scanner scr = new Scanner(line);
String built = "";
scr.useDelimiter("[^A-Za-Z]+|^)|^(|^ ");
while (scr.hasNext()){
built+= scr.next();
}
this.line = built.trim();
I also tried using a regex and .matches() but for some reason that screwed up the scanner. Any help on how to set up the delimiter would be appreciated!