Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

parse digit in string

ansari
7 - Meteor

Hi all

I have problem in solving my project in the field of parsing

I'm having my input like this 

PARLE COOKIES HIDE&SEEK ASTD 4*120g OP
BRITANNIA 50-50 MASKA CHASKA 4*120g OP
TANG POW CONC LEMON 500g*2 OP
KURKURE NAMK ASSORTED 3*85g OP
SANTOOR SOAP SNDL&ALMND MILK 4*125g

 

I need to parse only quantity of the product 

for example i need my output 

 

PARLE COOKIES HIDE&SEEK ASTD4
BRITANNIA 50-50 MASKA CHASKA4
TANG POW CONC LEMON2
KURKURE NAMK ASSORTED3
SANTOOR SOAP SNDL&ALMND MILK4

 

please Assist me 



 

6 REPLIES 6
BenMoss
ACE Emeritus
ACE Emeritus

Regex  is the tool of choice here. I approached the problem as follows.

 

Firstly identify and replace the 'size' with the word size, using the regex replace function with the following code: \d+g

 

This converts something like: bob 40*800g DS to bob 40*size DS and dave 400g*40 FO to dave size*40 FO

 

I then use the regex tool in 'parse' mode with the function: (\d+)

 

This will keep our remaining digits and parse them into a new column, which can be titled 'quantity'

 

Finally I built out a convoluted method for bringing back all the detail before the qunatity*volume is given.

 

Example attached.

 

Ben

 

MarqueeCrew
20 - Arcturus
20 - Arcturus
It looks like you want to find:

One or more digits followed by an asterisk followed by one or more digits followed by the letter "g".

Is that the pattern that you want?

If so, "\d+\*\d+g" is the pattern.

Cheers,

Mark
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
ansari
7 - Meteor

Thank you, Ben it works good.but for some records it takes first number of the line instead  of taking quantity.

here

I attached my exampleCapture.PNGCapture1.PNG

 

BenMoss
ACE Emeritus
ACE Emeritus

Arr sorry, I did not identify the instances where a string may contain other digits. Let me take another look.

 

Ben

BenMoss
ACE Emeritus
ACE Emeritus

Here is a new version, hopefully this works.

 

Ben

ansari
7 - Meteor

Thanks ben that works.

Sorry to say this.

my Field not only having "g" (gram). It also consists of lot of units such as "ml"(milliliter);"L" (Litre); "PULL"; "G" (Grams).for this cases it gives NULL.

how to come over this? It is  possible in Alteryx

Please assist me....

Labels