Convert comma separated string text to tuple list

Convert comma separated string text to tuple list

  

So suppose i have a string which contains various numbers separated by commas like this:

12213421342134, 1234213421342134, 1234213421341234

And i wish to convert to the following format which is a list of tuples separated by commas:

('12213421342134', 1) , ('1234213421342134', 1) , ('1234213421341234', 1)

How can i achieve this?

Solution

b_pal wrote:

So suppose i have a string which contains various numbers separated by commas like this:

12213421342134, 1234213421342134, 1234213421341234

And i wish to convert to the following format which is a list of tuples separated by commas:

('12213421342134', 1) , ('1234213421342134', 1) , ('1234213421341234', 1)

How can i achieve this?

Hi, 

You can use the String_Split Action from this extension ( https://www.outsystems.com/forge/component-details/67/Extension+Text/ ).

Here is a brief description on how to use them - https://success.outsystems.com/Documentation/10/Reference/OutSystems_APIs/Text_API


The following post might help you - https://www.outsystems.com/forums/discussion/33343/string-split/

Best Regards

Rodrigo Henriques


Solution

Hum...

If it is simple as in your example, in that the add number will always be the same, you can do something easier.
In an assign to your new string, put something like this in the expression:

"('" + Replace(YourOriginalString, ",", "',1), ('") + "',1)"

 Cheers.