Ashley
Ashley

Reputation: 55

Processing a user's input?

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 ?

Upvotes: 0

Views: 336

Answers (1)

Feanor
Feanor

Reputation: 670

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.

Upvotes: 1

Related Questions