I am new in java programming. My problem is that I would like to split the user input string from an EditText
to groups of 2,3,4,5 & 6.
For example, the input might look like: "the alarm clock in the table is noisy"
I would like to group them like this.
By 2: (the alarm) (alarm clock) (clock in) (in the) (the table) (table is) (is noisy)
By 3: (the alarm clock) (alarm clock in) (clock in the) (in the table) (the table is) (table is noisy)
By 4: (the alarm clock in) (alarm clock in the) (clock in the table) (in the table is) (the table is noisy)
Same goes to 5 & 6. Afterwards I store these in an array perhaps.
I only know how to split string through spaces or other delimiters. this is my code so far:
String[] text = editText.split(" ");
Log.d("Length", String.valueOf(text.length));
for (int i = 0; i < text.length; i++) {
count = i;
text[i] = text[i].trim();
Log.d("Create Response", text[i]);
params.add(new BasicNameValuePair("translate_me", text[i]));
}
But I don't have the slightest idea how to do this. Can someone help me?