Split a string

0
Hi, The other day I was looking for a way to split a string and I could not find a way to do it. The way I would do it in PHP is explode(“,”,$string). This will give me an array I can itterate through. How can I accomplish this in Mendix? Thank you in advance. Kind regards, Pascal
asked
4 answers
1

As Michiel Arts mentioned in a comment to the other answer, the Community Commons Library is the way to do it. There is a Java Action that accomplished exactly this (create an array of splitted string objects you can loop through).

answered
0

As you've probably found, there are no arrays in Mendix. The nearest to your requirement would be a List of Entities with a single String attribute.

How you approach this depends on your final requirements. It maybe iterating over the String calling the find and substring methods until you have no more results is the best approach.

If you are looking to parse CSV, then look at the CSV module in the App Store. This will split a line of data to create a single entity with multiple attributes.

If you have a more specific requirement, post it up and we can try to help.

answered
0

Hi Robert,

Thank you for your answer.

What I tried to accomplish was the following. I want to build some sort of approval monitoring system.

I am adding email addresses to that approval system. I would like to have the option to enter email addresses by seperating them with a comma or some other delimiter. After the submit button is clicked, the emailaddresses are put into a string and then this string is splitted and each email address is send an email.

This system is only to be used inside the company, not outside so I am not too worried about email being flagged as spam.

 

Kind regards,

Pascal

answered
0

I will look into the community commons library too.

Thanks

answered