-2

I need to parse the following expression:

Fertilizer abc 7-15-15 5KG BOX 250 KG 

in 3 fields:

  • The product description: Fertilizer abc 7-15-15
  • Size: 250
  • Size unit: KG

Do not know how to proceed. Please, any help and explanation?

luchonacho
  • 5,255
  • 3
  • 27
  • 41
PMig
  • 13
  • 4
  • Can you share a little more on what the raw text looks like? for example do you need 3 regexes to parse out/modify each segment, and where does BOX come from? or specifically 5KG? cause I dont see that listed in the product description you shared – Aurielle Perlmann Jul 09 '17 at 09:14
  • which flavor do you use? Or which language do you use? – Shakiba Moshiri Jul 09 '17 at 10:02
  • Fertilizer name 7-15-15 5KG BOX 250 KG Fertilizer name 10 LTS ... – PMig Jul 09 '17 at 12:49

1 Answers1

0

Try this in the alteryx REGEX Tool with Parse selected as the Method: ([A-z ]* [\d-]{6,8}) ([A-Z\d]{2,6}) (.{1,5}?) (\d*) ([A-Z]*)

You can test it at Regexpal to see the breakdown of each group but essentially the first set of brackets will get you your product description (text and spaces until 6-8 characters made up of digits and dashes), the 2nd & 3rd parts will deal with the erroneous info that you don't want, the 4th group will be just digits and the 5th group will be any text afterwards.

Note that this will change dramatically if your data has digits where there is characters currently etc.

You can always break it up into even smaller groups and then concatenate back together as well.

KaneG
  • 146
  • 4