Parsing and combining numbers from a text string

Hi All,

I’m just exploring a possible method of combining several flows into a single flow and wanted to see if something was possible.

I have a NetSuite saved search returning a string that looks like the example below. The data is looking at inventory quantities for child items across different locations;

“NL 0,NL 76,Re 23,Re 27,Re 34,Re 36,Re 38,Re 54,Re 57,Re 59,Re 86,UK 0,UK 28,UK 3,UK 6”

Is there a way I could take that data in a transformation stage, using handlebars and return the sum of all quantities beginning NL, all beginning RE and all beginning UK?

So if the example was;

“NL 2,NL 4,Re 3,Re 3,Re 1,UK 0,UK 1,UK 2,UK 6”

I would want to end up with 3 separate outputs;

NL = 6
RE = 7
UK = 9

The number of values returned in the original string is variable depending on how many child items there are for each parent.

Is this possible? Many thanks in advance!

@Matthew_Lacey .... i asked Celigo AI. Does this work?

Here's the text version of that handlebar expression:

{
  "NL": {{add (regexMatch loc_qty "[Nn][Ll] [0-9]+" 0 "g")}},
  "RE": {{add (regexMatch loc_qty "[Rr][Ee] [0-9]+" 0 "g")}},
  "UK": {{add (regexMatch loc_qty "[Uu][Kk] [0-9]+" 0 "g")}}
}
1 Like

Hi Tony,

Thanks for looking in to it and steering me in the direction of the AI assistant.
It’s not really working in that form, as it’s just returning the first value it finds a match for, rather than a total of all the matching values. So for example, where there are 2 ‘NL’ values; 0 & 76, it’s just returning the 0 rather than adding them to get 76.

I feel like regexMatch might be part of the solution though, so I’ll have a play around today and see what I can come up with.

Thanks!

I’ve taken a change of approach in the end. Couldn’t get this to work due to all the variables, so decided to go back to the start and change how the saved search works.

Perhaps it’s possible, but I couldn’t justify spending any more time on it.