Answered question

regexp for split string in array

I need to extract a data from a previous server response containing a string made up of data separated by a special caracter. How can I split my string to obtain the selected value with a regexp.

the string to split : (1069404¢0¢¢Faux¢Faux¢NO_QU_01069404 PR_QU_01069404¢PR_QU_01069404¢A1_QU_01069404¢¢¢36000¢CHATEAUROUX¢France¢0601020304¢0601020304¢0601020304¢0601020304¢0601020304¢0601020304)

Patrice C.
Patrice C.

Patrice C.

Level
0
2 / 100
points
Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

I agree with Neil. Another way would be to do it directy in the variable extractor panel using a custom decoder. As an example this one should work:

function decode(encodedValue) {
    var decodedValue = encodedValue.replace(/¢/g, "");
    //Apply decoding logic here.
    //JS Libraries can be used
    return decodedValue;
}

I replace your caracter by nothing but you can replace it by a blank space or anything else.

Did you find this useful ?

No (0)

Yes (0)

0% of users found this answer useful

Other answers

Neil W.
Neil W.

Neil W.

Level
2
1867 / 2000
points
Team

My suggestion would be to extract the full string then use a piece of javascript, the code would look something like this...

var theValue = theExtractedString.toString().split("¢")[0];

where 0 is the first value, 1 is the 2nd, etc