Start Free Trial

Alteryx Designer Desktop Discussions

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

Regex Parse logic not working correctly

AnandKumar1
8 - Asteroid

I've written a parse to split a record into multiple column.

Below is my input file on which some record has 4 different values , some has only 3 and some has 5

 

:25:A1BC 0055555 USD
:25:X1Y2 USD
:25:HK13 49000000 USD NY

 

And to achieve this i have written this into parse= (:25:)(\w+)(\s)(\d+)(\s)([A-Z]*[0-9]*)(\s)*([A-Z]*[0-9]*)

But this parse result is getting correct for 1st record line. but Null is coming for 2nd record line and 3rd is again right.

:25:A1BC0055555USD 
     
:25:HK13 49000000USDNY


This is required output

:25:A1BC0055555USD 
:25:X1Y2 USD 
:25:HK13 49000000USDNY

 

Can someone tell me what's going wrong here? Is the logic in parse wrong?

 

 

3 REPLIES 3
jdunkerley79
ACE Emeritus
ACE Emeritus

I think something like:

(:25:)(\w+)\s*(\d+)?\s([A-Z]*[0-9]*)\s*([A-Z]*[0-9]*)?

 

What I have done is marked a few blocks as optional (with a trailing ?) and made the spaces 0 or more.

 

Seems like it works with your example.

mceleavey
17 - Castor
17 - Castor

Hi @AnandKumar1 ,

 

I've attached the regex workflow for you.

 

mceleavey_0-1621854200198.png

 

M.

 



Bulien

Qiu
21 - Polaris
21 - Polaris

@AnandKumar1 
In oder to make it work, we need more data to test it I think 😁

Capture4.PNG

Labels
Top Solution Authors