Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Filter String Text

sfh22
5 - Atom

Hello guys,

 

So I know it's complicated but I would appreciate any insights that any of you can provide.

 

 

sfh22_1-1612805419978.png

 

So, I have such strings which I need to filter the number of grams that an item have.

For example from the string QUAKER OAT COOKIES HONEY NUT 9G   =>  I would like to replace the text with just the integer "9".

 

Some strings don't include any grams count   =>  so it's fine to drop down.

 

Thank you in advance.

 

2 REPLIES 2
Emil_Kos
17 - Castor
17 - Castor

Hi @sfh22,

 

Maybe you can try a data cleansing tool and choose that you want to keep only numbers? 

 

Data cleansing tool have functionalities that allow removing all letters from a string

 

https://help.alteryx.com/current/designer/data-cleansing-tool

SeanAdams
17 - Castor
17 - Castor

hey @sfh22 

 

The best way to do this kind of text parsing is with the regEx tool.   You will need to learn the language of regular expressions, but this is well worth doing because it's a key skill in data parsing.

In your particular case - the regular expression to use is .*?(\d+)G

Breaking this down:

  •  . means any character
  • .* means any character repeated
  • \d+ means a group of digits (plus is similar to * - star is "zero or more repeats" and plus is "1 or more repeats"
  • the brackets, in this way of using them, tells alteryx to keep the numbers

So this regex says "give me any series of 1 or more numbers which is followed by G and is at the end of a piece of text.    I've attached an Alteryx flow to this post

 

Resources:

 
Labels