How could I split a string into chunks of all available combinations? For example:
"12345"
Would output:
[1, 12, 123, 1234, 12345, 2, 23, 234, 2345, 3, 34, 345, 4, 45]
This is as far as I've gotten:
String title = "12345";
List<String> keywordsList = List();
String temp = "";
String temp2 = "";
for (int i = 0; i < title.length; i++) {
temp = temp + title[i];
if (temp.length > 1) temp2 = temp2 + title[i];
keywordsList.add(temp);
if (temp2.length != 0) keywordsList.add(temp2);
}
print(keywordsList);
return keywordsList;
},
Which results in:
[1, 12, 2, 123, 23, 1234, 234, 12345, 2345]
Super stuck now, will appreciate any help.
Thanks in advance!