If you download Community Commons from the Mendix Marketplace, you’ll find a Java Action called StringSplit that can do this. You pass in the string you want to split and the separator character, and it will return a List of objects containing the split strings.
If you don't want to use a Java action. You will need to use string functions in order to achieve this:
- First you have take a substring from the first wordt. This can be done by taking a substring from position 0 untill the first comma (find($inputstring, ,) -1).
- The string you get is the first word.
- Create an object of this string and execute the logic you need.
- Then you use a replace all function, where you replace the first word in the original string, with an empty string. replaceAll($inpuntstring, $stringfirstword, ‘’).
- Now you have the input string without the first word.
- Go back to step 1, check if another word is found, and if so, continue the logic. (If no comma is found the entire string should be processed, since this is then the last word).
In the CommunityCommons Module you have an action called “String Split”. There you can set your string that you want to split (‘Hello,My,World’) and the split parameter (‘,’). The return value will be a list of SplitItems where SplitItem/Value contains the words and SplitItem/Index will be the position of the word in the sentence.
You can then do what you want with those objects containing the words (e.g. loop over them and save each as an object, or with the index check if the 3rd word is ‘...’ or something like that).
Thank you all