Expand my Community achievements bar.

Join us at Adobe Summit 2024 for the Coffee Break Q&A Live series, a unique opportunity to network with and learn from expert users, the Adobe product team, and Adobe partners in a small group, 30 minute AMA conversations.
SOLVED

How to read 1 single string A|B|C|D from Launch and split into 4 entries in evar

Avatar

Community Advisor

Hello everyone,

 

How can I split this single string A|B|C|D from Launch into 4 differents entries?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

The simplest is with custom code:

 

var str = "A|B|C|D";
var values = str.split("|");
// values = ["A", "B", "C", "D"]

 

 

View solution in original post

11 Replies

Avatar

Correct answer by
Community Advisor

The simplest is with custom code:

 

var str = "A|B|C|D";
var values = str.split("|");
// values = ["A", "B", "C", "D"]

 

 

Avatar

Community Advisor

Hi yuhui, AA receives this string "A|B|C|D" via API. I would like to store in evar X (AA) A, B, C D as single entry not as string

Avatar

Community Advisor
@yuhuisg: It is useful approach but now we have evar X 1:ABC|2:DEF|3:KLN from Launch and I need to save into evar (report suite), ABC OR EDF OR KLN.

Avatar

Community Advisor
@Luca_Lattarini the solution is still the same: you need to use list variables

Avatar

Community Advisor
@yuhuisg, It works well, If I use List Variable but I have an import data from API 1.4 where I dont use List Variable. Can I use List Variable from API?

Avatar

Community Advisor

@Luca_LattariniI'm not familiar with using the API, unfortunately. But I assume that list variables should be supported.

Avatar

Community Advisor
@yuhuisg, I tried to use list2 with API 1.4 but I got an error. It is not supported. I m trying to read the string like this "1|2" by using this regex in Classification Builder((?:[^\\|]+|\\\|?)+). Any idea how to match 1 and 2? I tried ((?:[^\\|]+|\\\|?)+)[1] but it doesnt work.

Avatar

Community Advisor
@Luca_Lattarini also, I don't think Classification will work in your use case. Classification means that for your variable, you have defined 2 classifications for it (e.g. like 2 sub-variables), and you want to use "1" in the first classification, and "2" in the second classification. But you're splitting the "1|2" string "horizontally", when based on your original post, you want to split the string "vertically".