Alteryx Designer Desktop Discussions

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

REGEX - how to Tokenize numbers "starting with" certain numbers

ELPC
8 - Asteroid

Hi all, 

I have a Text column where PO numbers are entered into with some description of the project.  This text field can have multiple PO numbers and project descriptions.  I am trying to extract out just the various PO numbers and then taking only the last one entered.  My PO numbers can start with 4400XXXX, 4500XXXX, 4600XXXX, 4700XXXX, 4800XXXX or 4900XXXX.  I was able to use RegEx to tokenize each number sequence in one tool but that means I have to use 6 tools to get the 6 sequences. 

 

I used this expression for the first sequence:  ([4][4][0][0]\d+)  

 

Is there a way to write the expression so I do not have to use 6 separate tools or is there a way to do it in a formula tool?  Thank you.  

4 REPLIES 4
ehughes
9 - Comet

Hi @ELPC 

 

I would use the following expression:

4[4|5|6|7|8|9]00\d{4}

It picks up the 4 for the first digit, then the second digit has to be 4 or 5 or 6 or 7 or 8 or 9, that's followed by two zeros and then any 4 digits after that.

Hope that makes sense and hope it works for you

 

ehughes_0-1607644678011.png

 

ELPC
8 - Asteroid

Thank you so much!  That worked!  I knew there had to be an easier way.  Didn't know you could use the pipe to break them out like that.  Learned something new.  

ehughes
9 - Comet

Awesome! I still have a lot to learn about Regex myself 😊 But using the pipe as an 'or' operator can be so useful so I'm glad I could share that

joshuaburkhow
ACE Emeritus
ACE Emeritus

Just a tip here. You actually don't need the pipes. Just put them all in a list with brackets 😉 Also don't need the "00" as you push to the d{6} digit search 😉 

 

So you could also use this: 4[456789]\d{6}

 

joshuaburkhow_0-1607694827297.png

 

Joshua Burkhow - Alteryx Ace | Global Alteryx Architect @PwC | Blogger @ AlterTricks
Labels