I am getting user input on the column, row number and data they want to put in that place. How would I go about breaking the user input into pieces ? The user input will always be in the COLUMN ROW DATA format so is there any delimiter statement that I can use ?
1 Answer
If your user input is a string in the format:
<col> <row> <data>
You can use the split() method on the space (" ") to get an array of strings.
For example
input = "3 2 100";
inputs = input.split(" ");
column = inputs[0]; // "3"
row = inputs[1]; // "2"
data = inputs[2]; // "100"
If this isn't what you're looking for then please elaborate your question.
2 Comments
Ashley
if it there is a lot of spaces between them like 3 2 100 it wouldn't matter ?
Feanor
@Ashley Check this question for splitting on any whitespace: How do I split a string with any whitespace chars as delimiters?
find column# helloso it would go find in the column# the user gave the word hello. but a user can sayfind hello. so I have to process user input according to what the user gave me.