Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Regex to re-order key field

hellyars
13 - Pulsar

Okay easy Regex question.  See example below.

 

FIELD_1 is a key field used to join data.   The base pattern for the key is exemplified in Record #1.  

The base pattern is ^\d[A-Z]\-\d{7}[A-Z]{1,3}\-[A-Z]{1}.   

 

Records #2 and #3 add a 4 digit project code.  But, the project code should be appended to the base key.  

The pattern should be ^\d[A-Z]\-\d{7}[A-Z]{1,3}\-[A-Z]{1}\-.{4}.  

Records #2 and 3 are wrong.  They read, ^\d[A-Z]\-\d{7}[A-Z]{1,3}\-.{4}\-[A-Z]{1}

 

How do I correct. 

 

I tried using a Regex Tool set to Parse: (^.*?)(\-.{4})(\-Q) with the output set to $1 $3 $2.  That did not work. 

 

RecordIDFIELD_1DESIRED OUTCOME
14020X-99-R-0602143P-Q4020X-99-R-0602143P-Q
29113X-99-R-0303138P-2039-Q9113X-99-R-0303138P-Q-2039
39113X-99-R-1203110FS-78C9-Q9113X-99-R-1203110FS-Q-78C9
1 REPLY 1
hellyars
13 - Pulsar

Wait.  Got it.  It actually work.  Safari to Alteryx copy and paste problem, the expression was not coping over correctly.  Plus, I had to get rid of the spaces between $1$3$2

Labels
Top Solution Authors