0

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 ?

4
  • 2
    Post what you have tried so far, a sample of the input, and describe specifically what is not working as you want it. Commented Sep 7, 2011 at 6:15
  • 1
    please elebrate your question very clearly Commented Sep 7, 2011 at 6: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. Commented Sep 9, 2011 at 13:30
  • 1
    okay 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. Commented Sep 9, 2011 at 13:45

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

if it there is a lot of spaces between them like 3 2 100 it wouldn't matter ?
@Ashley Check this question for splitting on any whitespace: How do I split a string with any whitespace chars as delimiters?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.