开发者

Processing a user's input?

开发者 https://www.devze.com 2023-04-03 16:59 出处:网络
I am getting user input开发者_StackOverflow中文版 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 alwa

I am getting user input开发者_StackOverflow中文版 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 ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号