Selecting certain array element for extraction field

Hi, i have an issue regarding selecting a value from an array.

This is the sample of the txt file;
“***222222” “TA” “N2” “Office” “ahahah@hahah.com.au” “22 Haha Rd or PO BOX 22” “Cardiff” “Ha” “2222” “02 2222 9220” “02 2222 6266” “”

I have managed to extract and put the text into an array with the following javascript

a = data.extract(5,152,0,1,“
”);

var myRegexp =/“([^”]*)"/gi;
var myArray = ;

do {
//Each call to exec returns the next regex match as an array
var match = myRegexp.exec(a);
if (match != null)
{
//Index 1 in the array is the captured group if it exists
//Index 0 is the matched text, which we use if no captured group exists
myArray.push(match[1] ? match[1] : match[0]);
}
} while (match != null);

The following output is ;
[“2222”, “T”, “N1”, “2222 Office”, “2222@mmem.com.au”, “22222 Rd or PO BOX 22”, “2222”, “2222”, “2285”, “02 2222 9720”, “02 2222 6266”];

Please dont mind the difference in output data as I had to change the values from the original data.

My question is I want to use the first element of the array for a specific data extraction field,
And so on and so on for each respective data extraction such as
image

Field1 = myArray[0];
Field2 = myArray[1];

Currently The javascript works and the output field is
11.0 which is the total number of elements in the array.

How do i extract a targeted element for the data field.?

Welcome to our community, Maverick!

You were close. Simply store that script in an Action Step. After running it, all your elements are in your myArray variable.

Then add an extraction step with your 11 fields, each set to JavaScript mode, with the following code for each:

myArray[0]; // (or myArray[1], or myArray[2], etc.)

The process therefore looks like this:

image

Thank you so much Phil !

Glad to be a part of the community/

I will definitely proceed with this implementation step.

I have tried the solution as above, however i am still unable to extract the data from the array .

Following that i used javascript as described,

As you can see. even after referencing

myArray[0]; the field is not extracted . However the array is successfully extracted as i inputted the array into Field with the values 11.0 as seen in the picture just to demonstrate.

Sorry, I forgot to mention that I had to make a slight adjustment to your script:

var a=('"'+data.extract(5,152,0,1,""))
var myRegexp =/"([^"]*)"/gi;
var myArray = [];

var match = myRegexp.exec(a);
while (match) {
	myArray.push(match[1] || match[0]);
	match = myRegexp.exec(a);
}

Attached is a sample data mapping config that demonstrates what I did: ArrayExtract.OL-datamapper (4.0 KB)

Thank you very much !

It works perfectly, I forget that i extracted the text with the beginning extraction missing a parenthesis.