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 ?
Asked
Active
Viewed 322 times
0
-
2Post what you have tried so far, a sample of the input, and describe specifically what is not working as you want it. – Mat Sep 07 '11 at 06:15
-
1please elebrate your question very clearly – developer Sep 07 '11 at 06:15
-
@Ashley Your question is a bit vague. Could you edit it for clarity? Pretend you've never seen your application before, or know anything about the problem at hand. Your question needs to explain both things. – Tim Post Sep 09 '11 at 13:30
-
1okay so like I take in user inputs from the user and sometimes things are optional. Like A user can input `find column# hello` so it would go find in the column# the user gave the word hello. but a user can say `find hello`. so I have to process user input according to what the user gave me. – Ashley Sep 09 '11 at 13:45
1 Answers
1
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.

Feanor
- 670
- 1
- 4
- 9
-
if it there is a lot of spaces between them like 3 2 100 it wouldn't matter ? – Ashley Sep 07 '11 at 14:00
-
@Ashley Check this question for splitting on any whitespace: [How do I split a string with any whitespace chars as delimiters?](http://stackoverflow.com/questions/225337/how-do-i-split-a-string-with-any-whitespace-chars-as-delimiters) – Feanor Sep 07 '11 at 17:10