I'm try to go through a file that's formatted as follows:
f 5//10 3//2 6//3
f 9//3 20//15 3/20
etc.
I want to pull out the numbers, subtract them by some set number, and then output them. I'm using a scanner to read each line of the file, but next Int doesn't seem to work since I have the // between some of the numbers. I know there has to be some simple way to deal with this, but I'm having a hard time finding what to do.

BufferedReader, readLine(), and split("/+|\s+")

Thanks for the help, but I'm not sure what you mean by 'split'...it doesn't seem to be a method in either BufferedReader or Scanner.


Edit: Ah, I see - split is in String. But when I put the regular expression you provided into split, it says it's invalid. Sorry...I'm not good with regular expressions.

"\\s+" not "\s+"

String regex = ("[^\\d\\s]");
 String text = "f 5//10 3//2 6//3";
text.split(regex);

edit:
or

String regex = ("[\\s\\\\[^\\d]\\s]");

the above code pull out all the integer..

try yourself to get clear output.

And much more complicated than need be. simply split on one or more whitespace or one or more "/" characters (as I did) and ignore the first index.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.