Alteryx Designer Desktop Discussions

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

RegEx with mix of trailing spaces, number and letters

Ewbkm
7 - Meteor

Need help to parse the original data to 4 different columns?  Is it possible to use one RegEx to solve it?  

 

 
Original DataExpected RegEx Parse Results
Account ComboAccount NoSequence NoSub AccountCurrency
1001-600534-100-VTR-1014616      -AUD1001-600534-100 -VTR-1014616   AUD
1001-600534-101-VTR-1014619      -USD1001-600534-101 -VTR-1014619   USD
1001-100128-100-VTR-1012817H     -HKD1001-100128-100 -VTR-1012817H  HKD
1001-100915-100-VTR-1014460      -USD1001-100915-100 -VTR-1014460   USD
1001-100128-100-VTR-1012819H     -HKD1001-100128-100 -VTR-1012819H  HKD
1001-100874-500--2-USD1001-100874-5002 USD
1001-100874-510--2-HKD1001-100874-5102 HKD
1001-100874-588--2-CNH1001-100874-5882 CNH

 

5 REPLIES 5
binuacs
20 - Arcturus

@Ewbkm One way of doing this

image.png

Ewbkm
7 - Meteor

Thanks.  

 

I don't need the two dashes in front of the RegExOut2 (squence ## ) and need to get rid of the dash - in front of VTR in RegExOut3.  Can you help me more on this?  

TimN
13 - Pulsar

Similar approach

apathetichell
18 - Pollux

4 new fields in a formula tool:

1)

regex_replace([Account Combo],"^(\d+-\d+-\d+)(.*)","$1")

2)

if length(regex_replace([Account Combo],"^(\d+-\d+-\d+--)(\d+)(.*)","$2"))=1 then regex_replace([Account Combo],"^(\d+-\d+-\d+--)(\d+)(.*)","$2") else "" endif

3)

if regex_match([Account Combo],"^.*-\w{3}-\d+\w*.*") then regex_replace([Account Combo],"^(.*-)(\w{3}-\d+\w*)(.*)","$2") else "" endif

4)

right([Account Combo],3)

flying008
14 - Magnetar

Hi, @Ewbkm 

 

FYI.

 

 

^([\d-]{15})(--(\d{1,})|-([[:alnum:]-]*))[- \s]+([[:alpha:]]+?)$

 

 

录制_2023_11_01_08_50_41_76.gif

 

BTW, if you want to get the first '-' before 'VTR' in field [Sub Account], the use the expression to parse:

 

Spoiler
^([\d-]{15})(--(\d{1,})|([[:alnum:]-]*))[- \s]+([[:alpha:]]+?)$

 

Account ComboAccount NoSequence NoSub AccountCurrency
1001-600534-100-VTR-1014616      -AUD1001-600534-100 -VTR-1014616   AUD
1001-600534-101-VTR-1014619      -USD1001-600534-101 -VTR-1014619   USD
1001-100128-100-VTR-1012817H     -HKD1001-100128-100 -VTR-1012817H  HKD
1001-100915-100-VTR-1014460      -USD1001-100915-100 -VTR-1014460   USD
1001-100128-100-VTR-1012819H     -HKD1001-100128-100 -VTR-1012819H  HKD
1001-100874-500--2-USD1001-100874-5002 USD
1001-100874-510--2-HKD1001-100874-5102 HKD
1001-100874-588--2-CNH1001-100874-5882 CNH

 

 

******

If can help you get your want, please mark it as a solution and give a like for more share.

Labels